Liking cljdoc? Tell your friends :D

ws.clojure.extensions

A small library of useful 'language extensions' -- things are 'like' existing clojure.core functionality but with a small, useful extension.

condp-> -- an extension to cond-> that threads the expression through the predicate(s) as well as the result(s). condp->> -- an extension to cond->> that threads the expression through the predicate(s) as well as the result(s). condq -- a version of condp that accepts a unary predicate and omits the expr (that condp uses as the second argument to the predicate). dissoc-all -- an extension to dissoc that dissoc's a sequence of keys. flip -- a companion to partial that allows the first argument to be omitted (rather than the trailing arguments). Inspired by Haskell's flip. interleave-all -- an extension to interleave that uses all elements of the longer sequence argument(s). local-map -- produce a hash map from all, or a subset of, local bindings.

A small library of useful 'language extensions' -- things are 'like'
existing clojure.core functionality but with a small, useful extension.

condp-> -- an extension to cond-> that threads the expression
  through the predicate(s) as well as the result(s).
condp->> -- an extension to cond->> that threads the expression
  through the predicate(s) as well as the result(s).
condq -- a version of condp that accepts a unary predicate and omits the
  expr (that condp uses as the second argument to the predicate).
dissoc-all -- an extension to dissoc that dissoc's a sequence of keys.
flip -- a companion to partial that allows the first argument to be
  omitted (rather than the trailing arguments). Inspired by Haskell's flip.
interleave-all -- an extension to interleave that uses all elements
  of the longer sequence argument(s).
local-map -- produce a hash map from all, or a subset of, local bindings.
raw docstring

completablecljmacro

(completable & body)

Return a CompletableFuture that will evaluate the body asynchronously.

Can be deref'd, future-cancel'd, etc. Call then (below) on this to provide a function to call when the future completes.

Return a CompletableFuture that will evaluate the body asynchronously.

Can be deref'd, future-cancel'd, etc. Call then (below) on this to provide
a function to call when the future completes.
sourceraw docstring

condp->cljmacro

(condp-> expr & clauses)

Takes an expression and a set of predicate/form pairs. Threads expr (via ->) through each form for which the corresponding predicate is true of expr. Note that, unlike cond branching, condp-> threading does not short circuit after the first true test expression.

Takes an expression and a set of predicate/form pairs. Threads expr (via ->)
through each form for which the corresponding predicate is true of expr.
Note that, unlike cond branching, condp-> threading does not short circuit
after the first true test expression.
sourceraw docstring

condp->>cljmacro

(condp->> expr & clauses)

Takes an expression and a set of predicate/form pairs. Threads expr (via ->>) through each form for which the corresponding predicate is true of expr. Note that, unlike cond branching, condp->> threading does not short circuit after the first true test expression.

Takes an expression and a set of predicate/form pairs. Threads expr (via ->>)
through each form for which the corresponding predicate is true of expr.
Note that, unlike cond branching, condp->> threading does not short circuit
after the first true test expression.
sourceraw docstring

condqcljmacro

(condq pred & clauses)

Takes a unary predicate, and a set of clauses. Each clause can take the form of either:

test-expr result-expr

test-expr :>> result-fn

Note :>> is an ordinary keyword.

For each clause, (pred test-expr) is evaluated. If it returns logical true, the clause is a match. If a binary clause matches, the result-expr is returned, if a ternary clause matches, its result-fn, which must be a unary function, is called with the result of the predicate as its argument, the result of that call being the return value of condq. A single default expression can follow the clauses, and its value will be returned if no clause matches. If no default expression is provided and no clause matches, an IllegalArgumentException is thrown.

Takes a unary predicate, and a set of clauses.
Each clause can take the form of either:

test-expr result-expr

test-expr :>> result-fn

Note :>> is an ordinary keyword.

For each clause, (pred test-expr) is evaluated. If it returns
logical true, the clause is a match. If a binary clause matches, the
result-expr is returned, if a ternary clause matches, its result-fn,
which must be a unary function, is called with the result of the
predicate as its argument, the result of that call being the return
value of condq. A single default expression can follow the clauses,
and its value will be returned if no clause matches. If no default
expression is provided and no clause matches, an
IllegalArgumentException is thrown.
sourceraw docstring

dissoc-allclj

(dissoc-all m ks)

Given a map and a sequence of keys, dissoc them all.

Given a map and a sequence of keys, dissoc them all.
sourceraw docstring

exceptionallycljmacro

(exceptionally cf f)

Given a CompletableFuture and a function, if the future completes with an exception, invoke the function on that exception.

Given a CompletableFuture and a function, if the future completes
with an exception, invoke the function on that exception.
sourceraw docstring

flipclj

(flip f)
(flip f b)
(flip f b c)
(flip f b c d & more)

Like partial except you supply everything but the first argument. Also like Haskell's flip for single arity call.

Like partial except you supply everything but the first argument.
Also like Haskell's flip for single arity call.
sourceraw docstring

interleave-allclj

(interleave-all)
(interleave-all c1)
(interleave-all c1 c2)
(interleave-all c1 c2 & colls)

Like interleave, but stops when the longest seq is done, instead of the shortest.

Like interleave, but stops when the longest seq is done, instead of
the shortest.
sourceraw docstring

local-mapcljmacro

(local-map)
(local-map op & ks)

Turn all (or a subset of) locals into a hash map with keys named for their symbols (and their values).

For the subset case, op can be :with (or :only) or :without. The latter will use all the local bindings except the named ones; the former will use just the specified locals. ks can be bare symbols or keywords or strings.

Inspired by an example from @noisesmith on Slack.

Turn all (or a subset of) locals into a hash map with keys named for
their symbols (and their values).

For the subset case, `op` can be `:with` (or `:only`) or `:without`.
The latter will use all the local bindings except the named ones; the
former will use just the specified locals. `ks` can be bare symbols or
keywords or strings.

Inspired by an example from @noisesmith on Slack.
sourceraw docstring

thencljmacro

(then cf f)

Given a CompletableFuture and a function, when the future completes, invoke the function on its result.

Given a CompletableFuture and a function, when the future completes,
invoke the function on its result.
sourceraw docstring

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

× close