天天看點

clojure/core mapv

點我檢視原文

(ns $clojureDoc.core.mapv)
;; 使用方法:(mapv f coll) (mapv f c1 c2) (mapv f c1 c2 c3) (mapv f c1 c2 c3 & colls)
;; Returns a vector 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.
;; 傳回一個由每一個集合對應的項參與函數f運算後結果組成的向量,直到某一個集合項數用盡,其它集合的其餘項将被忽略
;; 函數f應該接受的參數與提供的集合個數相同

(println (mapv #(- (* 3 %1) 1) (range 1 3)))
;; => [2 5]

(println (mapv + [1 2 3] (iterate inc 1)))
;; => [2 4 6]
           

繼續閱讀