in reply to A classic use of prototypes: map2
I'm a big fan of this sort of thing. In fact my other favorite programming language, Haskell, has a built-in function called "zipWith" that does precisely this. Combined with lazy operators, this lets you do things like define the Fibonacci sequence:
fib = 1 : 1 : zipWith (+) fib (tail fib)where (+) is equivalent to your {$a+$b}, ":" is how you say "cons" or, arguably, unshift, and "tail" is how you say "cdr" or, arguably, @foo[1 .. $#foo], but without necessarily making a copy.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: A classic use of prototypes: map2
by tkil (Monk) on May 02, 2004 at 20:41 UTC |