Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Variable number of foreach loops (non-recursive solution)

by smls (Friar)
on Nov 28, 2013 at 17:44 UTC ( #1064853=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub nested_foreach(&@) {
      my $code = shift;
    ...
    my @c = ...;
    
    nested_foreach { say join ' ', @_ } \@a, \@b, \@c;
    
  2. or download this
    sub nested_foreach(&@) {
      ... # see above
    ...
        iterative => sub { nested_foreach { join("", @_) } @AoA },
        recursive => sub { nForX { join("", @_) } scalar @AoA, @AoA },
    };
    
  3. or download this
              s/iter iterative recursive
    iterative   1.86        --      -71%
    recursive  0.532      249%        --
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1064853]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (4)
As of 2022-05-27 13:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (95 votes). Check out past polls.

    Notices?