Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get even/odd indexed elements from a Collection(List of Maps) in Clojure

I have a List of Map, I need to get the even/odd indexed elements from that list in Clojure. I don't want to iterate thought the list with for loop. Is there any small or single_word function?

like image 693
Abimaran Kugathasan Avatar asked Aug 25 '11 06:08

Abimaran Kugathasan


1 Answers

user=> (take-nth 2 [0 1 2 3 4 5 6 7 8 9])
(0 2 4 6 8)
user=> (take-nth 2 (rest [0 1 2 3 4 5 6 7 8 9]))
(1 3 5 7 9)
like image 102
kotarak Avatar answered Oct 19 '22 03:10

kotarak