Liking cljdoc? Tell your friends :D

sicmutils.function

Procedures that act on Clojure's function and multimethod types, along with extensions of the SICMUtils generic operations to functions.

See the Function cljdocs for a discussion of generic function arithmetic.

Procedures that act on Clojure's function and multimethod types, along with
extensions of the SICMUtils generic operations to functions.

See [the `Function`
cljdocs](https://cljdoc.org/d/sicmutils/sicmutils/CURRENT/doc/data-types/function)
for a discussion of generic function arithmetic.
raw docstring

*strict-arity-checks*clj/s

If true, attempting to pass two functions of incompatible arity into any binary function, or into combine-arities, will throw. False by default.

If true, attempting to pass two functions of incompatible arity
into any binary function, or into [[combine-arities]], will throw. False by
default.
sourceraw docstring

arg-scaleclj/s

(arg-scale f & factors)

Takes a function f and a sequence of factors, and returns a new function that multiplies each factor by the corresponding argument of f. Too many or two few factors are ignored.

((arg-scale square 3) 4) ==> 144
((arg-scale square 3 2 1) 4) ==> 144
Takes a function `f` and a sequence of `factors`, and returns a new function
that multiplies each factor by the corresponding argument of `f`. Too many or
two few factors are ignored.

```clojure
((arg-scale square 3) 4) ==> 144
((arg-scale square 3 2 1) 4) ==> 144
```
sourceraw docstring

arg-shiftclj/s

(arg-shift f & shifts)

Takes a function f and a sequence of shifts, and returns a new function that adds each shift to the corresponding argument of f. Too many or two few shifts are ignored.

((arg-shift square 3) 4) ==> 49
((arg-shift square 3 2 1) 4) ==> 49
Takes a function `f` and a sequence of `shifts`, and returns a new function
that adds each shift to the corresponding argument of `f`. Too many or two few
shifts are ignored.

```clojure
((arg-shift square 3) 4) ==> 49
((arg-shift square 3 2 1) 4) ==> 49
```
sourceraw docstring

coerce-to-fnclj/s

(coerce-to-fn x arity)

Given a [[value/numerical?]] input x, returns a function of arity arity that always returns x no matter what input it receives.

For non-numerical x, returns x.

Given a [[value/numerical?]] input `x`, returns a function of arity `arity`
that always returns `x` no matter what input it receives.

For non-numerical `x`, returns `x`.
sourceraw docstring

combine-aritiesclj/s

(combine-arities)
(combine-arities a)
(combine-arities a b)

Returns the joint arity of arities a and b.

The joint arity is the loosest possible arity specification compatible with both a and b. Throws if a and b are incompatible.

Returns the joint arity of arities `a` and `b`.

The joint arity is the loosest possible arity specification compatible with
both `a` and `b`. Throws if `a` and `b` are incompatible.
sourceraw docstring

composeclj/s

(compose & fns)

Arity-preserving version of clojure.core/comp.

The arity of a composition is the arity of the rightmost (that is, first to be applied) function term in fns.

Arity-preserving version of `clojure.core/comp`.

The arity of a composition is the arity of the rightmost (that is, first to be
applied) function term in `fns`.
sourceraw docstring

function?clj/s

(function? f)

Returns true if f is of [[v/kind]] ::v/function, false otherwise.

Returns true if `f` is of [[v/kind]] `::v/function`, false otherwise.
sourceraw docstring

getclj/s

(get f k)
(get f k not-found)

For non-functions, acts like [[clojure.core/get]]. For function arguments (anything that responds true to function?), returns

(comp #(clojure.core/get % k) f)

If not-found is supplied it's passed through to the composed [[clojure.core/get]].

For non-functions, acts like [[clojure.core/get]]. For function
arguments (anything that responds true to [[function?]]), returns

```clojure
(comp #(clojure.core/get % k) f)
```

If `not-found` is supplied it's passed through to the
composed [[clojure.core/get]].
sourceraw docstring

get-inclj/s

(get-in f ks)
(get-in f ks not-found)

For non-functions, acts like [[clojure.core/get-in]]. For function arguments (anything that responds true to function?), returns

(comp #(clojure.core/get-in % ks) f)

If not-found is supplied it's passed through to the composed [[clojure.core/get-in]].

For non-functions, acts like [[clojure.core/get-in]]. For function
arguments (anything that responds true to [[function?]]), returns

```clojure
(comp #(clojure.core/get-in % ks) f)
```

If `not-found` is supplied it's passed through to the
composed [[clojure.core/get-in]].
sourceraw docstring

Iclj/s

Identity function. Returns its argument.

Identity function. Returns its argument.
sourceraw docstring

IArityclj/sprotocol

arityclj/s

(arity f)

Return the cached or obvious arity of f if we know it. Otherwise delegates to heavy duty reflection.

Return the cached or obvious arity of `f` if we know it. Otherwise
delegates to heavy duty reflection.
source

joint-arityclj/s

(joint-arity arities)

Find the most relaxed possible statement of the joint arity of the given sequence of arities. If they are incompatible, an exception is thrown.

Find the most relaxed possible statement of the joint arity of the given sequence of `arities`.
If they are incompatible, an exception is thrown.
sourceraw docstring

memoizeclj/s

(memoize f)

meta-preserving version of clojure.core/memoize.

The returned function will have a new :arity entry in its metadata with the arity of the original f; this is because the process used to figure out a function's arity will not work across the memoization boundary.

meta-preserving version of `clojure.core/memoize`.

The returned function will have a new `:arity` entry in its metadata with the
`arity` of the original `f`; this is because the process used to figure out a
function's arity will not work across the memoization boundary.
sourceraw docstring

seq-arityclj/s

(seq-arity xs)

Returns the most general arity compatible with the aritiies of all entries in the supplied sequence xs of values.

Returns the most general arity compatible with the aritiies of all entries in
the supplied sequence `xs` of values.
sourceraw docstring

with-arityclj/s

(with-arity f arity)
(with-arity f arity m)

Appends the supplied arity to the metadata of f, knocking out any pre-existing arity notation.

Optionally accepts a third parameter m of metadata to attach to the return function, in addition to the new :arity key.

Appends the supplied `arity` to the metadata of `f`, knocking out any
pre-existing arity notation.

Optionally accepts a third parameter `m` of metadata to attach to the return
function, in addition to the new `:arity` key.
sourceraw docstring

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

× close