A basic challenge of iterators
sub mymap(@list, &block) { my @result; while @list { push @result, &block(@list.shift); } @result; } my @lines = $file.lines; mymap(@lines, &block);
What happens to @lines after the call to mymap?
continued...Perl 6 | More laziness and lists | #14 |
sub mymap(@list, &block) { my @result; while @list { push @result, &block(@list.shift); } @result; } my @lines = $file.lines; mymap(@lines, &block);
What happens to @lines after the call to mymap?
continued...
Copyright © 2012 http://www.pmichaud.com/2012/pres/ |