Skip to content

Instantly share code, notes, and snippets.

@TimToady
Created March 1, 2012 16:52
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save TimToady/1951347 to your computer and use it in GitHub Desktop.
sub amb($var,*@a) {
"[{
@a.pick(*).map: {"||\{ $var = '$_' }"}
}]";
}
'' ~~ m/
:my ($a,$b,$c,$d);
<{ amb '$a', <the that a> }>
<{ amb '$b', <frog elephant thing> }>
<?{ substr($a,*-1,1) eq substr($b,0,1) }>
<{ amb '$c', <walked treaded grows> }>
<?{ substr($b,*-1,1) eq substr($c,0,1) }>
<{ amb '$d', <slowly quickly> }>
<?{ substr($c,*-1,1) eq substr($d,0,1) }>
{ say "$a $b $c $d" }
<!>
/;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment