Method: Lisp#zip
- Defined in:
- lib/carat/lisp.rb
#zip(fun, l, m) ⇒ Object
209 210 211 212 213 214 215 216 217 |
# File 'lib/carat/lisp.rb', line 209 def zip(fun, l, m) if null?(l) and null?(m) nil elsif null?(l) or null?(m) raise ArgumentError.new("zip with unequal length lists") else cons(fun.call(car(l), car(m)), zip(fun, cdr(l), cdr(m))) end end |