General purpose utility functions.
General purpose utility functions.
(concatv & vectors)
Concatenates the given sequences together into a vector.
Provided as an alternative to concat
, when a lazy sequence would be inappropriate.
Example:
(concatv [1 2] [3 4]) ; => [1 2 3 4]
(concat [1] [2] '(3 4) [5 6 7] #{9 10 8}) ; => (1 2 3 4 5 6 7 8 9 10)
Concatenates the given sequences together into a vector. Provided as an alternative to `concat`, when a lazy sequence would be inappropriate. Example: ```clj (concatv [1 2] [3 4]) ; => [1 2 3 4] (concat [1] [2] '(3 4) [5 6 7] #{9 10 8}) ; => (1 2 3 4 5 6 7 8 9 10) ```
(filter-by-keys pred m)
Return m
with only the key:value pairs whose keys cause pred
to evaluate truthily.
Example:
(filter-by-keys nil? {}) ; => {}
(filter-by-keys keyword? {:a 2 "b" 1 :c 4 :d 6 "e" 7}) ; => {:a 2 :c 4 :d 6}
Return `m` with only the key:value pairs whose keys cause `pred` to evaluate truthily. Example: ```clj (filter-by-keys nil? {}) ; => {} (filter-by-keys keyword? {:a 2 "b" 1 :c 4 :d 6 "e" 7}) ; => {:a 2 :c 4 :d 6} ```
(filter-by-values pred m)
Return m
with only the key:value pairs whose values cause pred
to evaluate truthily.
Example:
(filter-by-values nil? {}) ; => {}
(filter-by-values even? {:a 2 :b 1 :c 4 :d 6 :e 7}) ; => {:a 2 :c 4 :d 6}
Return `m` with only the key:value pairs whose values cause `pred` to evaluate truthily. Example: ```clj (filter-by-values nil? {}) ; => {} (filter-by-values even? {:a 2 :b 1 :c 4 :d 6 :e 7}) ; => {:a 2 :c 4 :d 6} ```
(remove-by-keys pred m)
Return m
with only the key:value pairs whose keys cause pred
to evaluate falsily.
Example:
(remove-by-keys nil? {}) ; => {}
(remove-by-keys keyword? {:a 2 "b" 1 :c 4 :d 6 "e" 7}) ; => {"b" 1 "e" 7}
Return `m` with only the key:value pairs whose keys cause `pred` to evaluate falsily. Example: ```clj (remove-by-keys nil? {}) ; => {} (remove-by-keys keyword? {:a 2 "b" 1 :c 4 :d 6 "e" 7}) ; => {"b" 1 "e" 7} ```
(remove-by-values pred m)
Return m
with only the key:value pairs whose values cause pred
to evaluate falsily.
Example:
(remove-by-values nil? {}) ; => {}
(remove-by-values even? {:a 2 :b 1 :c 4 :d 6 :e 7}) ; => {:b 1 :e 7}
Return `m` with only the key:value pairs whose values cause `pred` to evaluate falsily. Example: ```clj (remove-by-values nil? {}) ; => {} (remove-by-values even? {:a 2 :b 1 :c 4 :d 6 :e 7}) ; => {:b 1 :e 7} ```
(when-let+ bindings & body)
A multiple bindings version of clojure.core/when-let
.
If all bindings evaluate truthy, the body will be evaluated in an implicit do
in which all bindings are bound to the value of their test.
If any binding evaluates falsey, the body will not be evaluated and nil will be returned.
If multiple forms are provided, the last form will be returned.
If the bindings vector contains an invalid number of forms, an assertion error will be thrown.
Example:
(when-let+
[a 1 b 2]
(+ a b)) ; => 3
(when-let+
[a nil b 2]
(+ a b)) ; => nil
A multiple bindings version of `clojure.core/when-let`. If all bindings evaluate truthy, the body will be evaluated in an implicit `do` in which all bindings are bound to the value of their test. If any binding evaluates falsey, the body will not be evaluated and nil will be returned. If multiple forms are provided, the last form will be returned. If the bindings vector contains an invalid number of forms, an assertion error will be thrown. Example: ```clj (when-let+ [a 1 b 2] (+ a b)) ; => 3 (when-let+ [a nil b 2] (+ a b)) ; => nil ```
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close