Liking cljdoc? Tell your friends :D

had-utils.core


find-cycleclj

(find-cycle input update-fn)
(find-cycle input update-fn hash-fn)

Apply update-fn to input iteratively until a cycle is found. Return [start end] of the cycle, so applying start times is the same as end times. An optional hash-fn may be provided - in this case when two results have the same hash the cycle is reported.

Apply `update-fn` to `input` iteratively until a cycle is found.
Return [`start` `end`] of the cycle, so applying `start` times is the
same as `end` times. An optional `hash-fn` may be provided - in this
case when two results have the same hash the cycle is reported.
sourceraw docstring

find-cyclicclj

(find-cyclic input n update-fn)
(find-cyclic input n update-fn hash-fn)

See also find-cycle. Finds the result of applying update-fn to input n times by first detecting a cycle in the iteration using find-cyclic-equivalent and then computing based on that. Note that there is an inherent inefficiency because we compute first to find the cycle and then again to find the answer. This is necessary to support non-identity hash-fn.

See also `find-cycle`. Finds the result of applying `update-fn` to `input` `n`
times by first detecting a cycle in the iteration using `find-cyclic-equivalent`
and then computing based on that. Note that there is an inherent inefficiency
because we compute first to find the cycle and then again to find the answer.
This is necessary to support non-identity `hash-fn`.
sourceraw docstring

find-cyclic-equivalentclj

(find-cyclic-equivalent input n update-fn)
(find-cyclic-equivalent input n update-fn hash-fn)

See also find-cycle. Assuming applying update-fn repeatedly to input produces a cycle (or repeats a hash if the optional hash-fn is provided), finds an equivalent number of applications of update-fn to the provided n but less than the number needed to reach the end of the first cycle.

See also `find-cycle`. Assuming applying `update-fn` repeatedly to `input` produces a cycle
(or repeats a hash if the optional `hash-fn` is provided), finds an equivalent number of
applications of `update-fn` to the provided `n` but less than the number needed to reach the
end of the first cycle.
sourceraw docstring

fixed-point-nclj

(fixed-point-n f x)
(fixed-point-n f x max-iterations)

Iterate one argument function f on starting value x unil a fixed point is reached, returning [fixed-point n``] wherenis the number of iterations needed to reach the fixed point. Ifmax-iterationsis provided then will return nil after applyingf` that many times instead of running forever.

Iterate one argument function `f` on starting value `x`
unil a fixed point is reached, returning [`fixed-point` `n``]
where `n` is the number of iterations needed to reach the fixed point.
If `max-iterations` is provided then will return nil after applying
`f` that many times instead of running forever.
sourceraw docstring

flip-argsclj

(flip-args f)

Given a function f that takes at least two arguments returns a new function that reverses the order of the first two arguments

Given a function `f` that takes at least two arguments
returns a new function that reverses the order of
the first two arguments
sourceraw docstring

iterate-untilclj

(iterate-until f x pred)

Iterate one argument function f on starting value x and return the first iterate that makes pred true.

Iterate one argument function `f` on starting value `x`
and return the first iterate that makes `pred` true.
sourceraw docstring

reverse-argsclj

(reverse-args f)

Given a function f returns a new function that takes its arguments in the reverse order.

Given a function `f` returns a new function that takes its
arguments in the reverse order.
sourceraw docstring

update-vec-stateclj

(update-vec-state f initial-v)
source

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

× close