Skip to content

Instantly share code, notes, and snippets.

@P-Seebauer
Created January 14, 2016 19:28
Show Gist options
  • Save P-Seebauer/c755eeb9170cc1ca7f6f to your computer and use it in GitHub Desktop.
Save P-Seebauer/c755eeb9170cc1ca7f6f to your computer and use it in GitHub Desktop.
# possible solution for http://rosettacode.org/wiki/Amb
my @a =
(all «the that a»),
(all «frog elephant thing»),
(all «walked treaded grows»),
(all «slowly quickly»);
sub test (Str $l, Str $r) {
$l.ends-with($r.substr(0,1))
}
(sub ($w1, $w2, $w3, $w4){
return unless [and] test($w1, $w2), test($w2, $w3),test($w3, $w4);
say "$w1 $w2 $w3 $w4"
})(|@a);
# prints "that thing grows slowly"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment