Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: An iterator for (not "iterating") a recursive data structure.

by karlgoethebier (Abbot)
on Feb 12, 2015 at 15:27 UTC ( [id://1116510]=note: print w/replies, xml ) Need Help??


in reply to An iterator for (not "iterating") a recursive data structure.

"...AoA[oA[oA]...]]...iterate over the leaves...quit the iteration at an arbitrary point"

Perhaps Data::Rmap does the job?

use strict; use warnings; use Data::Rmap qw(rmap); my @data = [ [0], 1, 2, [ 3, 4, 5 ], 6, [ 7, 8, [ 9, 10 ], [ 11, [12] +, 13 ], ], 14 ]; my $something = 5; eval { rmap { $_ <= $something ? print : die; } @data; }; __END__ monks>rmap.pl 0 1 2 3 4 5

Edit: Forgot to copy&paste something ;-) ...and fixed some entities

Best regards, Karl

«The Crux of the Biscuit is the Apostrophe»

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (2)
As of 2024-04-25 18:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found