Problem 21 is: Write a function which returns the Nth element from a
sequence.
My solution is:
(fn [[f r] n]
(if (zero? n)
f
(recur r (dec n)
but it is marked as incorrect. Opening a REPL, and defining it with defn:
(defn mynth
[[f r] n]
(if
Hi,
there is no 6th element in your example. That's why you get nil.
Clojure 1.3.0
user= ((fn [[f r] n] (if (zero? n) f (recur r (dec n [4 5 6 7 8 9] 2)
6
Sincerely
Meikel
--
You received this message because you are subscribed to the Google
Groups Clojure group.
To post to this group,
Thanks !!!
It's wonderful how much time can be wasted because a bad copypaste :-)
Juan Manuel
On Friday, March 16, 2012 9:39:09 AM UTC+1, Meikel Brandmeyer (kotarak)
wrote:
Hi,
there is no 6th element in your example. That's why you get nil.
Clojure 1.3.0
user= ((fn [[f r] n] (if