-
-
Save smls/407f65d275810f41014b522148f2312a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use MONKEY-SEE-NO-EVAL; | |
sub amb ($var, *@a) { | |
my $r = # DEBUG | |
"[" ~ ("|| \{ $var = '$_' }" for @a) ~ "]"; | |
say "\n$r"; # DEBUG | |
$r # DEBUG | |
} | |
sub joins ($word1, $word2) { | |
my $r = # DEBUG | |
substr($word1,*-1,1) eq substr($word2,0,1); | |
say "{$r ?? "✓" !! "✕"} $word1:$word2"; # DEBUG | |
$r # DEBUG | |
} | |
'' ~~ 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 }> | |
{ say "$a $b $c" } | |
<{ amb '$d', <slowly quickly> }> | |
<?{ joins $c, $d }> | |
{ say "$a $b $c $d" } | |
<!> | |
/; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[|| { $a = 'the' } || { $a = 'that' } || { $a = 'a' }] | |
[|| { $b = 'frog' } || { $b = 'elephant' } || { $b = 'thing' }] | |
✕ the:frog | |
✓ the:elephant | |
[|| { $c = 'walked' } || { $c = 'treaded' } || { $c = 'grows' }] | |
✕ elephant:walked | |
✓ elephant:treaded | |
the elephant treaded | |
[|| { $d = 'slowly' } || { $d = 'quickly' }] | |
✕ treaded:slowly | |
✕ treaded:quickly |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment