On Wed, Dec 13, 2006 at 10:55:28AM +0200, Gaal Yahas wrote: : L<S04/"The do-once loop"/"A variant of do is gather"> stipulates the : results of a gather are flattened to a lazy list. I'm not sure how far : that flattenning goes, but one of these should do the trick, I think
It would only flatten a recursive structure with the help of something that recurses. The flattening of gather/take itself is only one level, insofar as the various takes are treated as "pushes" onto the list being gathered. : (Pugs does not yet implement gather/take): Actually, it does, but only the block form. The generalization to any statement (using C<do> syntax) was a very recent change. The following prints (1, 2, 3, 4, 5) in current pugs: #!/usr/bin/pugs my $a = [1,2,[3,4],5]; multi flattener ($x) { take $x; } multi flattener (Array @array) { for @array -> $elem { flattener($elem); } } sub flatten ([EMAIL PROTECTED]) { for @args -> $arg { return gather { flattener($arg) } } } $a.flatten.perl.say; Larry