in reply to What new tutorials would you like to see in Tutorials?

I've been meaning to write a tutorial on closures, but I'm short on real-world examples and I don't want to plagiarize from such beasts as Why I like functional programming... any suggestions?

(Yes, I'm hijacking ybiC's thread for my own, possibly nefarious, purposes. Nothing to see here, move along, nothing to see....)

--
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!

  • Comment on Re: What new tutorials would you like to see in Tutorials?

Replies are listed 'Best First'.
Re: Re: What new tutorials would you like to see in Tutorials?
by shotgunefx (Parson) on Sep 18, 2002 at 04:39 UTC
    <plug>Iterators</plug> are one good real-world use.

    -Lee

    "To be civilized is to deny one's nature."

      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!