> I don't understand how is this expression evaluated to get the shown result > > (apply map list (partition 2 [ 1 2 3 4 5 ])) => ((1 3) (2 4))
This is equivalent to - (map list '(1 2) '(2 4) '(5)) > removing the apply I got this: > > (map list (partition 2 [ 1 2 3 4 5 ])) => (((1 2)) ((3 4))) > > how is the apply changing the result? I'm not able to see the reasoning > behind this code. Can someone help me with this? As you can see, apply here is kind of "unwrapping" the input list (the one returned by partition). Apply takes a function, some (optional) arguments to the fn and a list of more args which it unwraps and calls the function on. For example - (apply + '(1 2 3 4)) is equivalent to (+ 1 2 3 4) We can also do - (apply + 1 2 '( 3 4)) which is equivalent to - (+ 1 2 3 4) Hope this helps. Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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