oke, Then I think I have to work with a if then :
The second test is already a vector but the thirth not (= (__ ["a" "b" "c"]) "b") (= (__ [[1 2] [3 4]]) [1 2]) I tried already the nth but I was also failing on the first. I think because of count because you cannot know how many values you have. (fn secondlast [v] (nth v (-(count v)1))) Roelof Op zondag 4 mei 2014 16:49:45 UTC+2 schreef Lee: > > > On May 4, 2014, at 10:42 AM, Roelof Wobben <rwo...@hotmail.com<javascript:>> > wrote: > > > For 4clojure I have to find the second to last item. > > > > So I did this: > > > > (fn secondlast [v] > > (get v (-(count v)1))) > > > > Now it's only failing at this test : (= (__ (list 1 2 3 4 5)) 4) > > > > Can anyone tell me where I did take the wrong way. > > > The "get" function with integer keys works for vectors but not for lists: > > => (get [7 8 9] 1) > 8 > => (get '(7 8 9) 1) > nil > > So one option would be to call "vec" on the list before calling get: > > => (get (vec '(7 8 9)) 1) > 8 > > Another option would be to use "nth" instead of "get". > > -Lee > > -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.