in reply to Re^5: Using lazy list with a for loop
in thread Using lazy list with a for loop
hence you need to switch to while and add an iterator method ->each to your API °That would now be the ideal for me, but don't you need to instantiate the iterator before calling it? Like:while (my ($widget) = $api->each( $item->{sets}{widgets})) { ... }
I wonder if you can combine the intializer with the iterator in a single call and have it rebless itself on the first call. Algorithm::Combinatorics does something similar.my $iter = $api->each( $item->{sets}{widgets} ); while (my ($widget) = $iter->()) { ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Using lazy list with a for loop
by LanX (Saint) on Jan 03, 2023 at 15:32 UTC |