I am porting some examples from Paul Graham's "On Lisp" book.
I have a problem with this one (fig 5. 4 page 67):
(defun fif (if then &optional else)
#'(lambda (x)
(if (funcall if x)
(funcall then x)
(if else (funcall else x)))))
My implementation:
(defn fif [iff then & else]
(fn [x]
(if (iff x)
(then x)
(if else
((first else) x)))))
When running:
(map #(fif even? (fn [x] (* 2 x))) [3 4])
I got:
java.lang.IllegalArgumentException: Wrong number of args passed to:
user$eval--5905$fn
I don't see where the number of parameters is wrong.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---