Collection helper functions.
Collection helper functions.
(alternate n coll)
Return a list of lists containing the items coll modulo n.
Return a list of lists containing the items coll modulo n.
(any-true? coll)
Returns a boolean if any value in coll is logically true. Deprecated: Use (any? coll).
Returns a boolean if any value in coll is logically true. Deprecated: Use (any? coll).
(any? coll)
(any? pred coll)
Returns a boolean representing if any value in coll is true. If pred is given, return if any value in coll satisfies pred.
Returns a boolean representing if any value in coll is true. If pred is given, return if any value in coll satisfies pred.
(create-map & vars)
Return a map with a list of variable's name as keys and the variable's values as value.
Return a map with a list of variable's name as keys and the variable's values as value.
(deep-merge & vals)
Like merge, but merges maps recursively. If vals are not maps, the last value wins.
Like merge, but merges maps recursively. If vals are not maps, the last value wins.
(deep-merge-with f & vals)
Like merge-with, but merges maps recursively. If vals are not maps, (apply f vals) determines the winner.
Like merge-with, but merges maps recursively. If vals are not maps, (apply f vals) determines the winner.
(distinct-by ident coll)
Like distinct, but using ident as the identity function for elements.
Example: (distinct-by :b [{:a 2, :b 7} {:a 3, :b 7} {:a 4, :b 8}]) => [{:a 2, :b 7} {:a 4, :b 8}]) (distinct-by second [[:a 2] [:b 2] [:b 3]]) => [[:a 2] [:b 3]] (= (distinct-by identity [1 1 2 3 4 4 5]) (distinct [1 1 2 3 4 4 5])) => true
Like distinct, but using ident as the identity function for elements. Example: (distinct-by :b [{:a 2, :b 7} {:a 3, :b 7} {:a 4, :b 8}]) => [{:a 2, :b 7} {:a 4, :b 8}]) (distinct-by second [[:a 2] [:b 2] [:b 3]]) => [[:a 2] [:b 3]] (= (distinct-by identity [1 1 2 3 4 4 5]) (distinct [1 1 2 3 4 4 5])) => true
(gapmap f coll)
Returns a lazy sequence consisting of the result of applying f to all adjacent values of coll. f should be a function taking 2 arguments. If coll contains less than 2 items, it is returned and f is not called.
Returns a lazy sequence consisting of the result of applying f to all adjacent values of coll. f should be a function taking 2 arguments. If coll contains less than 2 items, it is returned and f is not called.
(pmapcat f & colls)
Like mapcat but with parallelized map.
Like mapcat but with parallelized map.
(sequential! x)
Ensure x is sequential. If x is nil, nil is returned. Deprecated, use to-sequence instead.
Ensure x is sequential. If x is nil, nil is returned. Deprecated, use to-sequence instead.
(sort-maps-by coll & ks)
Sort a collection of maps on multiple keys. Items with a missing key have precedence.
Example: (sort-maps-by [{:a 2 :b 2} {:a 1} {:a 2 :b 1}] :a :b) => [{:a 1 :b 2} {:a 2 :b 1} {:a 2 :b 2}]
Sort a collection of maps on multiple keys. Items with a missing key have precedence. Example: (sort-maps-by [{:a 2 :b 2} {:a 1} {:a 2 :b 1}] :a :b) => [{:a 1 :b 2} {:a 2 :b 1} {:a 2 :b 2}]
(to-list x)
Like list, but (to-list nil) returns nil.
Like list, but (to-list nil) returns nil.
(to-sequence x)
Like sequence, but (to-sequence nil) returns nil.
Like sequence, but (to-sequence nil) returns nil.
(to-vector x)
Like vector, but (to-vector nil) returns nil.
Like vector, but (to-vector nil) returns nil.
(tree-seq+ branch?
children
root
&
[{:keys [parallel? limit]
:or {parallel? true limit Double/POSITIVE_INFINITY}}])
Like tree-seq but, optionally, parallelized and with max. traversion limit.
Like tree-seq but, optionally, parallelized and with max. traversion limit.
(unit coll)
Returns the value in a collection if it only contains one item; also know as singleton.
Returns the value in a collection if it only contains one item; also know as singleton.
(|> & args)
Piping/Thrushing, similar to F#'s or OCaml |>, or Haskells $. Limitations: Args are not evaluated lazily and functions can only take one argument (as last argument). Deprecated with Clojure 1.5, use clojure.core/-> or clojure.core/->> instead.
Piping/Thrushing, similar to F#'s or OCaml |>, or Haskells $. Limitations: Args are not evaluated lazily and functions can only take one argument (as last argument). Deprecated with Clojure 1.5, use clojure.core/-> or clojure.core/->> instead.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close