Liking cljdoc? Tell your friends :D

sicmutils.util.stream

This namespace contains various standard sequences, as well as utilities for working with strict and lazy sequences.

This namespace contains various standard sequences, as well as utilities for
working with strict and lazy sequences.
raw docstring

powersclj/s

(powers n)
(powers n x)

Returns an infinite sequence of x * n^i, starting with i == 0. x defaults to 1.

Returns an infinite sequence of `x * n^i`, starting with i == 0. `x` defaults
to 1.
sourceraw docstring

pprintclj/s

(pprint n xs)

Realizes and pretty-prints n elements from the supplied sequence xs.

Realizes and pretty-prints `n` elements from the supplied sequence `xs`.
sourceraw docstring

scanclj/s

(scan f & {:keys [present init] :or {present identity}})

Returns a function that accepts a sequence xs, and performs a scan by:

  • Aggregating each element of xs into
  • the initial value init
  • transforming each intermediate result by present (defaults to identity).

The returned sequence contains every intermediate result, after passing it through present (not init, though).

This is what distinguishes a scan from a 'fold'; a fold would return the final result. A fold isn't appropriate for aggregating infinite sequences, while a scan works great.

Arities:

  • the three-arity version takes init value, f fold function and present.
  • the two arity version drops init, and instead calls f with no arguments. The return value is the initial aggregator.
  • The 1-arity version only takes the merge fn and defaults present to identity.
Returns a function that accepts a sequence `xs`, and performs a scan by:

- Aggregating each element of `xs` into
- the initial value `init`
- transforming each intermediate result by `present` (defaults to `identity`).

The returned sequence contains every intermediate result, after passing it
through `present` (not `init`, though).

This is what distinguishes a scan from a 'fold'; a fold would return the final
result. A fold isn't appropriate for aggregating infinite sequences, while a
scan works great.

Arities:

- the three-arity version takes `init` value, `f` fold function and `present`.
- the two arity version drops `init`, and instead calls `f` with no arguments.
The return value is the initial aggregator.
- The 1-arity version only takes the `merge` fn and defaults `present` to
`identity`.
  
sourceraw docstring

seq-limitclj/s

(seq-limit xs)
(seq-limit xs
           {:keys [minterms maxterms tolerance convergence-fn fail-fn]
            :or {minterms 2
                 tolerance (Math/sqrt v/machine-epsilon)
                 convergence-fn (close-enuf? tolerance)}})

Accepts a sequence, iterates through it and returns a dictionary of this form:

{:converged? <boolean> :terms-checked <int> :result <sequence element>}

:converged? is true if the sequence reached convergence by passing the tests described below, false otherwise.

:terms-checked will be equal to the number of items examined in the sequence.

:result holds the final item examined in the sequence.

Optional keyword args:

:convergence-fn user-supplied function of two successive elements in xs that stops iteration and signals convergence if it returns true.

:fail-fn user-supplied function of two successive elements in xs that stops iteration and signals NO convergence (failure!) if it returns true.

:minterms seq-limit won't return until at least this many terms from the sequence have been processed.

:maxterms seq-limit will return (with :converged? false) after processing this many elements without passing any other checks.

:tolerance A combination of relative and absolute tolerance. defaults to sqrt(machine epsilon).

Accepts a sequence, iterates through it and returns a dictionary of this form:

{:converged? <boolean>
 :terms-checked <int>
 :result <sequence element>}

`:converged?` is true if the sequence reached convergence by passing the tests
described below, false otherwise.

`:terms-checked` will be equal to the number of items examined in the
sequence.

`:result` holds the final item examined in the sequence.

## Optional keyword args:

`:convergence-fn` user-supplied function of two successive elements in `xs`
that stops iteration and signals convergence if it returns true.

`:fail-fn` user-supplied function of two successive elements in `xs` that
stops iteration and signals NO convergence (failure!) if it returns true.

`:minterms` `seq-limit` won't return until at least this many terms from the
sequence have been processed.

`:maxterms` `seq-limit` will return (with `:converged? false`) after
processing this many elements without passing any other checks.

`:tolerance` A combination of relative and absolute tolerance. defaults to
`sqrt(machine epsilon)`.
sourceraw docstring

zenoclj/s

(zeno n)
(zeno n x)

Returns an infinite sequence of x / n^i, starting with i == 0. x defaults to 1.

Returns an infinite sequence of x / n^i, starting with i == 0. `x` defaults to
1.
sourceraw docstring

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

× close