> > (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))

Actually, since no pad collection is supplied,  the partition call returns

((1 2) (3 4))

So the apply variant (unwrapping the collection) is equivalent to....

(map list '(1 2) '(3 4))

Which is different to the plain call which looks like:

(map list '((1 2) (3 4)))

Now, map has a cool feature when called with multiple collections. From the
docs ....

map
(map f coll)
(map f c1 c2)
(map f c1 c2 c3)
(map f c1 c2 c3 & colls)

Returns a lazy sequence consisting of the result of applying f to the
set of first items of each coll, followed by applying f to the set
of second items in each coll, until any one of the colls is
exhausted. Any remaining items in other colls are ignored. Function
f should accept number-of-colls arguments.

so the final result is equivalent to

((list (first '(1 2)) (first (3 4))) (list (second '(1 2)) (second '(3 4)))

Which becomes:

((list 1 3) (list 2 4))

Which is the result you see - hope that helps

Neale
{t: @sw1nn, w:sw1nn.com <http://sw1nn.com.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

Reply via email to