in reply to Re: Dynamic function chains?
in thread Dynamic function chains?
In your solution, you are not constructing a composite subroutine, but instead iterating over all of them in the loop: $val = $_->( $val ) for @ops;
Wouldn't a composite subroutine be more efficient?
There's a trivial mistake in your solution in that it performs the operations in the reverse order (which is fixed by using
reverse @ARGVin the map statement).
I was aiming to keep the order, because then if you want:
f(g(h(x)))
you can say:
funcs.pl -f -g -h
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Dynamic function chains?
by BrowserUk (Patriarch) on Sep 15, 2004 at 15:26 UTC |