Map functions are quite special. First, let's look at a simple function:
user=> (def f (fn [x] (+ 2 x)))#'user/fuser=> (map f [2 4 7])(4 6 9)
Define an F function, accept a parameter, and then return the result after + 2.
Map accepts two parameters. The first is the F function, and the second is an array. Use the three elements in the array to call the F function in sequence. The result of each call is added to a list and returned.
Map document:
-------------------------clojure.core/map([f coll] [f c1 c2] [f c1 c2 c3] [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.nil
There is also a more advanced usage, such:
user=> (def f (fn [x y] (+ x y)))#'user/fuser=> (map f [2 4] [9 0])(11 4)
Here, the F function accepts two parameters, so the number of sets after map must be two. The running result should be:
(F (2 9) (f (4 0 )))
That is, (11 4)
This map is a little similar to the map reduce idea.