Hmm... iterators on anonymous functions could be fun, especially if you're doing a bunch of numerical code.
sub get_iter { my ($subref) = @_; my $i = 0; return sub { print "f($i) is ", &$subref($i++), "\n"; } } my $iter = &get_iter(sub {shift; $_*2}); for (0..20) { &$iter; }
I had actually thought, "well, what about iterators?", but somehow my brain turned that into "yeah, bind an array into the scope of a function, that's really useful". Thanks shotgunefx!
--
F
o
x
t
r
o
t
U
n
i
f
o
r
m
Found a typo in this node? /msg me
The hell with paco, vote for Erudil!
In reply to Re(3): What new tutorials would you like to see in Tutorials?
by FoxtrotUniform
in thread What new tutorials would you like to see in Tutorials?
by ybiC
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |