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

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

step-state-on-inputclj

(step-state-on-input initial-state step-f input-seq)

Take an initial-state, a function step-f that produces a new state based on a current state and piece of input, and a sequence of input input-seq and return the final state after stepping over all the input.

Take an `initial-state`, a function `step-f` that
produces a new state based on a current state and
piece of input, and a sequence of input `input-seq`
and return the final state after stepping over all
the input.
sourceraw docstring

update-vec-stateclj

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

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

× close