RosettaCodeData/Task/Amb/Raku/amb-2.raku
2023-07-01 13:44:08 -04:00

17 lines
541 B
Raku

# The Task #
my @firstSet = «the that a»;
my @secondSet = «frog elephant thing»;
my @thirdSet = «walked treaded grows»;
my @fourthSet = «slowly quickly»;
.say for doAmb [@firstSet, @secondSet, @thirdSet, @fourthSet];
sub doAmb( @lol ) { # Takes out the correct sentences.
my @sentences = map *.join(" "), [X] @lol;
grep &isAmb, @sentences;
}
sub isAmb( $sentence ) { # Checks `$sentence` for correctness.
$sentence !~~ / (.) " " (.) <!{$0 eq $1}> / # <https://docs.raku.org/language/regexes#Regex_boolean_condition_check>
}