Liking cljdoc? Tell your friends :D

sicmutils.util.aggregate

Utilities for aggregating sequences.

Utilities for aggregating sequences.
raw docstring

generic-sumclj/s

(generic-sum xs)
(generic-sum f low high)

Sums either:

  • a series xs of numbers, or
  • the result of mapping function f to (range low high)

Using the generic sicmutils.generic/+ function.

Sums either:

- a series `xs` of numbers, or
- the result of mapping function `f` to `(range low high)`

Using the generic [[sicmutils.generic/+]] function.
sourceraw docstring

groupclj/s

(group minus plus invert id)
(group minus plus invert id annihilate?)

Similar to monoid for types with invertible elements. Accepts:

  • binary minus and (associative) plus functions
  • a unary negate function
  • an element id that obeys (plus id other) == (plus other id) == other
  • optionally, an annihilate? function that should return true for any x such that (plus x <any>) == x.

Accepts a binary aggregation function plus and an identity element id and returns a multi-arity function that will reduce its arguments via plus. A 0-arity call returns id.

If the annihilate? function is supplied, then if the aggregation produces a value that returns (annihilate? true) at any point, the reduction will return immediately.

Similar to [[monoid]] for types with invertible elements. Accepts:

- binary `minus` and (associative) `plus` functions
- a unary `negate` function
- an element `id` that obeys `(plus id other) == (plus other id) == other`
- optionally, an `annihilate?` function that should return true for any `x`
  such that `(plus x <any>) == x`.

Accepts a binary aggregation function `plus` and an identity element `id` and
returns a multi-arity function that will reduce its arguments via `plus`. A
0-arity call returns `id`.

If the `annihilate?` function is supplied, then if the aggregation produces a
value that returns `(annihilate? true)` at any point, the reduction will
return immediately.
sourceraw docstring

halt-atclj/s

(halt-at pred)

Returns a transducer that ends transduction when pred (applied to the aggregation in progress) returns true for an aggregation step.

NOTE: This transducer should come first in a chain of transducers; it only inspects the aggregate, never the value, so putting it first will prevent unnecessary transformations of values if the aggregate signals completion.

Returns a transducer that ends transduction when `pred` (applied to the
aggregation in progress) returns true for an aggregation step.

NOTE: This transducer should come first in a chain of transducers; it only
inspects the aggregate, never the value, so putting it first will prevent
unnecessary transformations of values if the aggregate signals completion.
sourceraw docstring

kahan-sumclj/s

(kahan-sum)
(kahan-sum [sum c] x)

Implements a fold that tracks the summation of a sequence of floating point numbers, using Kahan's trick for maintaining stability in the face of accumulating floating point errors.

Implements a fold that tracks the summation of a sequence of floating point
numbers, using Kahan's trick for maintaining stability in the face of
accumulating floating point errors.
sourceraw docstring

merge-fnclj/s

(merge-fn compare add zero? make)

NOTE that the returned function recurs on increasing indices internally instead of walking through the lists directly. This method of traversing vectors is more efficient, and this function is called so often that the performance gain is worth it, and reads almost like the explicit sequence traversal.

NOTE that the returned function recurs on increasing indices internally instead
of walking through the lists directly. This method of traversing vectors is
more efficient, and this function is called so often that the performance gain
is worth it, and reads almost like the explicit sequence traversal.
sourceraw docstring

monoidclj/s

(monoid plus id)
(monoid plus id annihilate?)

Accepts a binary (associative) aggregation function plus and an identity element id and returns a multi-arity function that will combine its arguments via plus. A 0-arity call returns id.

optionally takes an annihilate? function that should return true for any x such that (plus x <any>) == x.

If the annihilate? function is supplied, then if the aggregation produces a value that returns (annihilate? true) at any point, the reduction will return immediately.

Accepts a binary (associative) aggregation function `plus` and an identity
element `id` and returns a multi-arity function that will combine its
arguments via `plus`. A 0-arity call returns `id`.

optionally takes an `annihilate?` function that should return true for any `x`
such that `(plus x <any>) == x`.

If the `annihilate?` function is supplied, then if the aggregation produces a
value that returns `(annihilate? true)` at any point, the reduction will
return immediately.
sourceraw docstring

scanning-sumclj/s

(scanning-sum xs)
(scanning-sum f low high)

Returns every intermediate summation from summing either:

  • a series xs of numbers, or
  • the result of mapping function f to (range low high)

Using Kahan's summation trick behind the scenes to keep floating point errors under control.

Returns every intermediate summation from summing either:

- a series `xs` of numbers, or
- the result of mapping function `f` to `(range low high)`

Using Kahan's summation trick behind the scenes to keep floating point errors
under control.
sourceraw docstring

sumclj/s

(sum xs)
(sum f low high)

Sums either:

  • a series xs of numbers, or
  • the result of mapping function f to (range low high)

Using Kahan's summation trick behind the scenes to keep floating point errors under control.

Sums either:

- a series `xs` of numbers, or
- the result of mapping function `f` to `(range low high)`

Using Kahan's summation trick behind the scenes to keep floating point errors
under control.
sourceraw docstring

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

× close