Liking cljdoc? Tell your friends :D

wing.core

Namespace providing extensions to clojure's standard library

Namespace providing extensions to clojure's standard library
raw docstring

apply-ifclj/s

(apply-if x pred f)

Conditionally applies (f x) if pred returns true, otherwise returns x.

Conditionally applies `(f x)` if `pred` returns `true`, otherwise returns `x`.
sourceraw docstring

apply-whenclj/s

(apply-when x pred f)

Conditionally applies (f x) if pred returns true, otherwise returns nil

Conditionally applies `(f x)` if `pred` returns `true`, otherwise returns nil
sourceraw docstring

argclj/s

(arg n)

Returns a function which will take any number of arguments and return the 1-based index argument of n. Mostly useful for composition.

user=> ((a 1) 1 2 3) 1

Returns a function which will take any number of arguments and return
the 1-based index argument of `n`. Mostly useful for composition.

user=> ((a 1) 1 2 3)
1
sourceraw docstring

arityclj/s

(arity n f & static-args)

Return a variant of f that will only accept n arguments.

Useful for coercing polyvariadic functions into fixed arity ones.

Optionally takes &args which will be applied after the first n arguments.

Return a variant of `f` that will only accept `n` arguments.

Useful for coercing polyvariadic functions into fixed arity ones.

Optionally takes `&args` which will be applied after the first `n`
arguments.
sourceraw docstring

assert-argsclj/smacro

(assert-args & pairs)

assert-args lifted from clojure.core. Mostly useful for writing other macros

assert-args lifted from clojure.core. Mostly useful for writing other macros
sourceraw docstring

assert-infoclj/smacro

(assert-info expr msg info)

A variant of assert that throws an ex-info based exception.

A variant of `assert` that throws an `ex-info` based exception.
sourceraw docstring

assoc-someclj/s

(assoc-some m & {:as kvs})

Like clojure.core/assoc but only associates the key and value if the val is some?.

Like `clojure.core/assoc` but only associates the key and value if the `val` is `some?`.
sourceraw docstring

avgclj/s

(avg & args)

Variadic function which will average args. Returns nil on empty collections

Variadic function which will average `args`. Returns nil on empty collections
sourceraw docstring

comprclj/s

(compr & fs)

Composes the provided reducer functions fs.

This essentially behaves exactly as comp but is variadic where additional arguments will be passed to each function.

Composes the provided reducer functions `fs`.

This essentially behaves exactly as `comp` but is variadic where additional arguments will be
passed to each function.
sourceraw docstring

dedupe-byclj/s

(dedupe-by f)
(dedupe-by f coll)

Returns a lazy sequence of the elements of coll, removing any consecutive elements that return duplicate values when passed to a function f.

Returns a stateful transducer when no collection is provided.

See also distinct-by

Returns a lazy sequence of the elements of coll, removing any **consecutive**
elements that return duplicate values when passed to a function f.

Returns a stateful transducer when no collection is provided.

See also `distinct-by`
sourceraw docstring

deep-mergeclj/s

(deep-merge x & [y & maps])

Similar to merge, but nested maps will be merged.

If any non-nested map value is duplicated, the right associated value will be kept. This includes scenarios where a left-bound map is merged with a right-bound primitive.

Similar to merge, but nested maps will be merged.

If any non-nested map value is duplicated, the right associated value will be
kept. This includes scenarios where a left-bound map is merged with a
right-bound primitive.
sourceraw docstring

dissoc-inclj/s

(dissoc-in m path)

Like clojure.core/dissoc but takes a path like clojure.core/get-in

Like `clojure.core/dissoc` but takes a path like `clojure.core/get-in`
sourceraw docstring

distinct-byclj/s

(distinct-by f)
(distinct-by f coll)

Returns a lazy sequence of the elements of coll with elements that return non-distinct values from f removed.

Returns a stateful transducer when no collection is provided.

See also dedupe-by.

Returns a lazy sequence of the elements of coll with elements that return non-distinct
values from `f` removed.

Returns a stateful transducer when no collection is provided.

See also `dedupe-by`.
sourceraw docstring

ensure-ascendingclj/s≠

clj
(ensure-ascending)
(ensure-ascending f)
(ensure-ascending coll)
(ensure-ascending f coll)
cljs
(ensure-ascending)
(ensure-ascending f-or-coll)
(ensure-ascending f coll)

Returns a stateful transducer that will ensure that only items that are ascending (using compare) will be emitted.

Optionally takes an f which will be used to access the value.

If called with a coll returns a lazy sequence.

Returns a stateful transducer that will ensure that only items that are ascending
(using `compare`) will be emitted.

Optionally takes an `f` which will be used to access the value.

If called with a `coll` returns a lazy sequence.
sourceraw docstring

extractclj/s

(extract map keys)

Returns a tuple of a vector of the vals of keys and map with keys removed.

Example:

(extract {:name "Bob" :age 42 :weight 200} [:age :weight]) ;; [[42 200] {:name "Bob"}]

Returns a tuple of a vector of the vals of `keys` and `map` with `keys` removed.

Example:

(extract {:name "Bob" :age 42 :weight 200} [:age :weight])
;; [[42 200] {:name "Bob"}]
sourceraw docstring

fexclj/s

(fex f ex-val)

Similar clojure.core/fnil. Returns a function which will call f when called and return ex-val in the case that any exception occurs.

Similar `clojure.core/fnil`. Returns a function which will call `f` when called
and return `ex-val` in the case that any exception occurs.
sourceraw docstring

filter-keysclj/s

(filter-keys f)
(filter-keys f map)

Return a transducer which will only match map-entries for which the pred called on keys returned logical true.

If called with map, will return a new map executing the transducer.

Return a transducer which will only match map-entries for which the
`pred` called on keys returned logical `true`.

If called with `map`, will return a new map executing the transducer.
sourceraw docstring

filter-valsclj/s

(filter-vals f)
(filter-vals f map)

Return a transducer which will only match map-entries for which the pred called on values returned logical true.

If called with map, will return a new map executing the transducer.

Return a transducer which will only match map-entries for which the
`pred` called on values returned logical `true`.

If called with `map`, will return a new map executing the transducer.
sourceraw docstring

find-firstclj/s

(find-first pred coll)
(find-first pred extract coll)

Returns the first item matching pred in coll.

Optionally takes an extract function which will be applied iff the matching item is not nil.

Example:

(find-first :primary :email [{:primary false :email "bob@gmail.com"} {:primary true :email "foo@bar.com"}])

Returns the first item matching `pred` in `coll`.

Optionally takes an `extract` function which will be applied iff the matching item is not `nil`.

Example:

(find-first :primary :email [{:primary false :email "bob@gmail.com"}
                            {:primary true :email "foo@bar.com"}])
sourceraw docstring

find-pathsclj/s

(find-paths pred coll)

Returns a sequence of vector paths for which pred returns true.

For nested maps, it will be called on the pred will be called with the val of the map entry.

Note that this performs a pre-walk and in the case of nested maps or vectors, pred will be called with them before traversing their children.

Returns a sequence of vector paths for which `pred` returns true.

For nested maps, it will be called on the `pred` will be called with the `val` of the map entry.

Note that this performs a pre-walk and in the case of nested maps or vectors, `pred` will be
called with them before traversing their children.
sourceraw docstring

group-byclj/s

(group-by f coll)
(group-by f g coll)
(group-by f g into coll)

Similar to clojure.core/group-by. Returns a map with keys of f applied to items in coll.

Optionally takes a function g which will be applied to the values.

Lastly, takes an into collection, which will be used to create the base collection at each key. This allows you to specify grouping into sets or vectors.

Similar to `clojure.core/group-by`. Returns a map with keys of
`f` applied to items in `coll`.

Optionally takes a function `g` which will be applied to the values.

Lastly, takes an `into` collection, which will be used to create the base collection at each key.
This allows you to specify grouping into sets or vectors.
sourceraw docstring

guardclj/s

(guard pred)
(guard pred x)

Return nil unless (pred x), then return x.

The unary form returns a partially applied guard.

Useful for condp.

Return `nil` unless `(pred x)`, then return `x`.

The unary form returns a partially applied `guard`.

Useful for `condp`.
sourceraw docstring

index-byclj/s

(index-by f coll)
(index-by f g coll)

Indexes a coll by the value returned by f. Returns a map.

Optionally takes a function g which will be applied to the val in the map.

user=> (index-by :name [{:name "Bob" :age 42}]) {"Bob" {:name "Bob" :age 42}}

user=> (index-by :name :age [{:name "Bob" :age 42}]) {"Bob" 42}

Indexes a `coll` by the value returned by `f`. Returns a map.

Optionally takes a function `g` which will be applied to the val in the map.

user=> (index-by :name [{:name "Bob" :age 42}])
{"Bob" {:name "Bob" :age 42}}

user=> (index-by :name :age [{:name "Bob" :age 42}])
{"Bob" 42}
sourceraw docstring

indistinctclj/s

(indistinct)
(indistinct coll)

Returns elements in a sequence that appear more than once.

Only returns successive elements that have been seen before.

If called without a collection, returns a stateful transducer.

user=> (indistinct [1 2 1 2 2 3 4 5 1]) (1 2 2 1)

Returns elements in a sequence that appear more than once.

Only returns successive elements that have been seen before.

If called without a collection, returns a stateful transducer.

user=> (indistinct [1 2 1 2 2 3 4 5 1])
(1 2 2 1)
sourceraw docstring

inspectclj/s

(inspect v)
(inspect msg v)
(inspect msg f v)

A function useful for println debugging. Prints the value (and an optional message) and returns it.

A function useful for println debugging. Prints the value (and an optional
message) and returns it.
sourceraw docstring

make-mapclj/smacro

(make-map & args)

Packs a sequence of variables into a map with keywords bound to the same name as the variables

Packs a sequence of variables into a map with keywords bound to the same name
as the variables
sourceraw docstring

map-keysclj/s

(map-keys f)
(map-keys f map)

Returns a transducer for mapping f over all keys in a map-entry.

If called with map, returns a new map with f applied over all keys.

Returns a transducer for mapping `f` over all keys in a map-entry.

If called with `map`, returns a new map with `f` applied over all keys.
sourceraw docstring

map-leavesclj/s

(map-leaves f)
(map-leaves f map)

Returns a transducer for mapping f over all leaf values in a map-entry. Nested maps will be traversed.

If called with map returns a new map with f applied over all leaves.

Returns a transducer for mapping `f` over all leaf values in a map-entry. Nested maps will be
traversed.

If called with `map` returns a new map with `f` applied over all leaves. 
sourceraw docstring

map-valsclj/s

(map-vals f)
(map-vals f map)

Returns a transducer for mapping f over all values in a map-entry.

If called with map, returns a new map with f applied over all values.

Returns a transducer for mapping `f` over all values in a map-entry.

If called with `map`, returns a new map with `f` applied over all values.
sourceraw docstring

ns-keysclj/s

(ns-keys ns)
(ns-keys ns map)

Returns a transducer which will namespace all keys in a map.

If called with map returns a new map executing the transducer.

Returns a transducer which will namespace all keys in a map.

If called with `map` returns a new map executing the transducer.
sourceraw docstring

partition-keysclj/s

(partition-keys map keys)

Similar to clojure.core/select-keys but returns a vector of two maps. The first is the map with the selected keys, while the other is the original map with the keys removed.

Similar to `clojure.core/select-keys` but returns a vector of two maps. The first is
the map with the selected `keys`, while the other is the original `map` with the `keys` removed.
sourceraw docstring

randclj/s

(rand n)
(rand low high)

Behaves just like clojure.core/rand but optionally accepts a lower bound.

Behaves just like `clojure.core/rand` but optionally accepts a lower bound.
sourceraw docstring

random-uuidclj/s

(random-uuid)

Return a random-uuid. Cljc port of the clojurescript variant

Return a random-uuid. Cljc port of the clojurescript variant
sourceraw docstring

remove-keysclj/s

(remove-keys f)
(remove-keys f map)

Return a transducer which will only match map-entries for which the pred called on keys returned logical false.

If called with map, will return a new map executing the transducer.

Return a transducer which will only match map-entries for which the
`pred` called on keys returned logical `false`.

If called with `map`, will return a new map executing the transducer.
sourceraw docstring

remove-valsclj/s

(remove-vals f)
(remove-vals f map)

Return a transducer which will only match map-entries for which the pred called on values returned logical false.

If called with map, will return a new map executing the transducer.

Return a transducer which will only match map-entries for which the
`pred` called on values returned logical `false`.

If called with `map`, will return a new map executing the transducer.
sourceraw docstring

roundclj/s

(round n)
(round n precision)

Rounds n to the given precision

Rounds `n` to the given `precision`
sourceraw docstring

standard-deviationclj/s

(standard-deviation & args)

Varidic function wheich will return the standard deviation of the provided args. Returns nil on empty collections

Varidic function wheich will return the standard deviation of the provided `args`. Returns `nil`
on empty collections
sourceraw docstring

sumclj/s

(sum & args)

Variadic function which will sum args. Treats nil as 0.

Variadic function which will sum `args`. Treats nil as 0.
sourceraw docstring

unfoldclj/s

(unfold f initial)

Produces a lazy sequence by invoking f with initial.

f should return a tuple of an item and new state.

If the item is nil nothing will be emitted.

If f returns nil the sequence will terminate.

See also: iterate

Produces a lazy sequence by invoking f with initial.

`f` should return a tuple of an item and new state.

If the item is `nil` nothing will be emitted.

If `f` returns `nil` the sequence will terminate.

See also: `iterate`
sourceraw docstring

update-if-existsclj/s

(update-if-exists m & {:as kfns})

Like clojure.core/update, but only calls f if the k exists in the m.

Like `clojure.core/update`, but only calls `f` if the `k` exists
in the `m`.
sourceraw docstring

update-if-someclj/s

(update-if-some m & {:as kfns})

Like clojure.core/update, but only calls f if the k exists in the m and it has a non-nil value.

Like `clojure.core/update`, but only calls `f` if the `k` exists
in the `m` and it has a non-nil value.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close