diff options
| -rw-r--r-- | challenge-064/simon-proctor/raku/ch-2.raku | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/challenge-064/simon-proctor/raku/ch-2.raku b/challenge-064/simon-proctor/raku/ch-2.raku new file mode 100644 index 0000000000..435ddf90b0 --- /dev/null +++ b/challenge-064/simon-proctor/raku/ch-2.raku @@ -0,0 +1,13 @@ +#!/usr/bin/env raku + +use v6.d; + +#| Given a string and a list of other strings return those in the main string in order +sub MAIN ( + Str $haystack, #= Target string to search + *@needles #= Strings to search for +) { + my @out = @needles.map( { $_ => $haystack.index($_) } ).grep( { $_.value.defined } ).sort( { $^a.value <=> $^b.value } ).map( *.key ); + (.say for @out ) if @out; + "0".say unless @out; +} |
