RosettaCodeData/Task/Amb/Perl-6/amb-3.pl6
2016-12-05 22:15:40 +01:00

22 lines
463 B
Raku

sub amb($var,*@a) {
"[{
@a.pick(*).map: {"||\{ $var = '$_' }"}
}]";
}
sub joins ($word1, $word2) {
substr($word1,*-1,1) eq substr($word2,0,1)
}
'' ~~ m/
:my ($a,$b,$c,$d);
<{ amb '$a', <the that a> }>
<{ amb '$b', <frog elephant thing> }>
<?{ joins $a, $b }>
<{ amb '$c', <walked treaded grows> }>
<?{ joins $b, $c }>
<{ amb '$d', <slowly quickly> }>
<?{ joins $c, $d }>
{ say "$a $b $c $d" }
<!>
/;