(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.
(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`.
(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.
(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
(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.
(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.
(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.
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close