diff options
| author | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-03-24 11:07:03 +0000 |
|---|---|---|
| committer | Simon Proctor <simon.proctor@zoopla.co.uk> | 2020-03-24 11:07:03 +0000 |
| commit | 17a8f5c086c67baf6f75789527b2a75e9231e84e (patch) | |
| tree | ad2fff2a71ecc98b8319bf7c4a6ca8e7eb72f2d2 /challenge-053/simon-proctor | |
| parent | 2b32380c48492ce9b835a149e937a4ae7050bbf5 (diff) | |
| download | perlweeklychallenge-club-17a8f5c086c67baf6f75789527b2a75e9231e84e.tar.gz perlweeklychallenge-club-17a8f5c086c67baf6f75789527b2a75e9231e84e.tar.bz2 perlweeklychallenge-club-17a8f5c086c67baf6f75789527b2a75e9231e84e.zip | |
Rewrite to fully functional
Diffstat (limited to 'challenge-053/simon-proctor')
| -rw-r--r-- | challenge-053/simon-proctor/raku/ch-2.p6 | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/challenge-053/simon-proctor/raku/ch-2.p6 b/challenge-053/simon-proctor/raku/ch-2.p6 index f68bb6f615..17f8554429 100644 --- a/challenge-053/simon-proctor/raku/ch-2.p6 +++ b/challenge-053/simon-proctor/raku/ch-2.p6 @@ -12,15 +12,16 @@ sub MAIN ( UInt $count is copy where 1 <= * <= 5; ) { my @strings = (''); - while $count > 0 { - $count--; - my @next = (); - for @strings -> $string { - @next.push( |valid-next( $string ) ); - } - @strings = @next; - } - .say for @strings; + + .say for process( @strings, $count ); +} + +multi sub process( @list, 0 ) { + @list; +} + +multi sub process( @list, $count ) { + process( @list.map( { valid-next( $_ ) } ).flat, $count - 1 ); } multi sub valid-next( '' ) { |
