Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
(map vector [1 2 3] [4 5])
会给:
([1 4] [2 5])
这里 3 被丢弃。
如果我想自动将那些太短的序列填充到最大长度怎么办?
例如,如果我想得到,惯用的方式是什么
([1 4] [2 5] [3 nil])
(defn map-all [f & colls] (lazy-seq (when (some seq colls) (cons (apply f (map first colls)) (apply map-all f (map rest colls)))))) (map-all vector [1 2 3] [4 5]) ;=> ([1 4] [2 5] [3 nil])