in reply to Subroutine chaining idiom requested
$agenda = [ sub { "Hello" }, sub { scalar reverse shift }, sub { chop +shift } ]; chain($agenda, [ ]); ### BEGIN GOLF MODE ### sub chain($$) { my@x=@{+pop};foreach(@{+shift}){@x=$_->(@x)}@x } ### END GOLF MODE ###
Update: Fixed argument-modification error, thanks to tilly for pointing that out.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re (tilly) 2: Subroutine chaining idiom requested
by tilly (Archbishop) on May 24, 2001 at 07:24 UTC |