potpuri.core
assoc-first
added in 0.2.1
(assoc-first coll where v)
Finds the first element in collection matching where parameter and
replaces that with v.
Implementation depends on collection type.
assoc-if
added in 0.2.0
(assoc-if m key val)
(assoc-if m key val & kvs)
Assoc key-values pairs with non-nil values into map.
assoc-in-path-vals
added in 0.1.0
(assoc-in-path-vals c)
Re-created a map from it's path-vals extracted with (path-vals).
conjv
added in 0.2.0
(conjv coll el)
Append an element to a collection. If collection is nil,
creates vector instead of sequence.
Usable with update-in, ->
consv
added in 0.2.0
(consv coll el)
Prepend an element to a collection. Returns a vector.
Usable with update-in, ->
deep-merge
added in 0.2.0
(deep-merge strategy & values)
(deep-merge values)
Recursively merges maps.
If the first parameter is a keyword it tells the strategy to
use when merging non-map collections. Options are
- :replace, the default, the last value is used
- :into, if the value in every map is a collection they are concatenated
using into. Thus the type of (first) value is maintained.
dissoc-in
added in 0.1.0
(dissoc-in m [k & ks :as keys])
Dissociates an entry from a nested associative structure returning a new
nested structure. keys is a sequence of keys. Any empty maps that result
will not be present in the new structure.
find-first
added in 0.2.0
(find-first coll where)
Find first value from collection which mathes the where parameter.
Check find-index for documentation on where parameter.
Usable with ->
find-index
added in 0.2.0
(find-index coll where)
Find index of vector which matches the where parameter.
If where parameter is:
- a fn, it's used as predicate as is
- a map, a predicate is created which checks if value in collection has
same values for each key in where map
- Something which implements IFn, e.g. keywords and sets, is used as is
- any value, a predicate is created which checks if value is identitical
Usable with ->
fn->
macro
added in 0.1.0
(fn-> & body)
Creates a function that threads on input with some->
fn->>
macro
added in 0.1.0
(fn->> & body)
Creates a function that threads on input with some->>
map-keys
added in 0.2.0
(map-keys f coll)
Map the keys of given associative collection using function.
map-of
macro
added in 0.1.0
(map-of & syms)
creates map with symbol names as keywords as keys and
symbol values as values.
map-vals
added in 0.2.0
(map-vals f coll)
Map the values of given associative collection using function.
path-vals
added in 0.1.0
(path-vals m)
Returns vector of tuples containing path vector to the value and the value.
update-first
added in 0.2.1
(update-first coll where f & args)
Finds the first element in collection matchin where parameter
and updates that using f. F is called with current value and
rest of update-first params.
Implementation depends on collection type.
wrap-into
added in 0.2.0
(wrap-into coll v)
Wrap non-collection values into given collection.
Collections are only put into the collection (non-wrapped).
Examples:
(wrap-into [] :a) => [:a]
(wrap-into [] [:a]) => [:a]
(wrap-into #{} [:a]) => #{:a}