# New Ticket Created by Timothy Bollman # Please include the string: [perl #130160] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/Ticket/Display.html?id=130160 >
It appears that when iterating lazily through a list that's been flattened (the first time), sometimes certain elements are not reached. For background I was writing some code that used a trie, and was attempting to find the word "inclusive" out of input trigrams. I have cleared away as much of the surrounding code as I could to provide a minimal test case. If you enable the commented line (or otherwise iterate through the @partials list at least once first), the output will be correct. Thanks, Tim Bollman use v6; sub find-words(@partials) { state $output = ''; # my @a = @partials.kv; for @partials.kv -> $i, $word { my $backup = $output; $output ~= $word; take $output; find-words(@partials[0 ..^ $i, $i ^..^ +@partials].flat()); $output = $backup; } } my @found = gather find-words(<ive lus inc>); .say for @found; # ive # ivelus # lus # lusive # lusiveinc # lusinc # lusincive # inc # incive