Stable marriage problem: Difference between revisions
m
→{{header|Perl 6}}: usage of two hashes updated
(Kotlin: with block idiom) |
SqrtNegInf (talk | contribs) m (→{{header|Perl 6}}: usage of two hashes updated) |
||
Line 4,050:
</pre>
=={{header|Perl 6}}==
{{Works with|rakudo|2016.10}}
{{trans|Perl}}
<lang perl6>my %he-likes =
Line 4,077 ⟶ 4,078:
;
my %fiancé;
my %fiancée;
Line 4,112 ⟶ 4,110:
sub check-stability {
my @instabilities = gather for
if he-prefers($m, $w) and she-prefers($w, $m) {
take "\t$w prefers $m to %fiancé{$w} and $m prefers $w to %fiancée{$m}";
Line 4,127 ⟶ 4,125:
}
sub unmatched-guy {
sub preferred-choice($guy) { %he-likes{$guy}.first: { not %proposed{"$guy $_" } } }
Line 4,144 ⟶ 4,142:
{{out}}
<pre>Matchmaking:
bea and fred
▲ abi dumped abe for jon
dee and col
▲ ivy dumped dan for abe
▲ fay and dan
Stablility:
Perturb:
Stablility:
=={{header|PicoLisp}}==
|