-
-
Save smls/9f11b70574f7088c5922 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
#!/usr/bin/env perl6 | |
use v6; | |
sub infix:<joins> ($a,$b) { | |
$a.substr(*-1,1) eq $b.substr(0,1) ?? "$a $b" !! Empty; | |
} | |
say <the that a> Xjoins | |
<elephant thing> Xjoins | |
<walked treaded grows> Xjoins | |
<slowly quickly>; | |
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
#!/usr/bin/env perl6 | |
use v6; | |
sub infix:<lf> ($a,$b) { | |
next unless try $a.substr(*-1,1) eq $b.substr(0,1); | |
"$a $b"; | |
} | |
multi dethunk(Callable $x) { try take $x() } | |
multi dethunk( Any $x) { take $x } | |
sub amb (*@c) { gather @c».&dethunk } | |
say first *, do | |
amb(<the that a>, { }) Xlf | |
amb(<frog elephant thing>) Xlf | |
amb(<walked treaded grows>) Xlf | |
amb(<slowly quickly>, { }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment