Liking cljdoc? Tell your friends :D

hiphip.array

Macros for iteration on generic arrays. This namespace provides versions that can iterate over arbitrary mixtures of array types, but the arrays must be appropriately type hinted for good performance. The specific array type namespaces (e.g. hiphip.double) offer versions of these macros that do not require type hints, but only work on arrays of the corresponding type.

All these macros use binding forms that look like:

[[i x] xs]

This binds i to the current index and x to the ith element of xs. The index-variable is optional, but there must be at least one array binding. You can have as many array bindings as you want. For example:

[x xs y ys z zs...] <expression involving x, y>)

Iteration is parallel and not nested, ulike for and doseq. Therefore, in

[[i1 x] xs [i2 y] ys [i3 z] zs ...] <expression involving i1, x, i2, y, i3, z> ```

the index-variables i1, i2, and i3 will have the same value.

You can specify a range for the operations. The default range is from 0 to the length of the first array in the bindings.

[[i x] xs :range [0 10]]

The bindings also support :let, which works like a regular let in the inner loop. In the typed namespaces, it casts to the array type (for speedy math), e.g.

[x xs :let [alpha 5 delta (- x 9)]] <expression involving x, alpha, delta>

Be aware that :let explicitly disallows shadowing the array bindings, e. g. (afill! [myvar xs :let [myvar 5]] myvar) throws an IllegalArgumentException. Do also note that destructuring syntax is not supported.

Macros for iteration on generic arrays. This namespace provides
versions that can iterate over arbitrary mixtures of array types,
but the arrays must be appropriately type hinted for good
performance. The specific array type namespaces (e.g.
`hiphip.double`) offer versions of these macros that do not require
type hints, but only work on arrays of the corresponding type.

All these macros use binding forms that look like:

[[i x] xs]

This binds `i` to the current index and `x` to the ith element of
xs. The index-variable is optional, but there must be at least one
array binding. You can have as many array bindings as you want. For
example:

[x xs
 y ys
 z zs...] <expression involving x, y>)

Iteration is parallel and not nested, ulike `for` and `doseq`.
Therefore, in

[[i1 x] xs
 [i2 y] ys
 [i3 z] zs ...]
<expression involving i1, x, i2, y, i3, z> ```

the index-variables i1, i2, and i3 will have the same value.

You can specify a range for the operations. The default range is
from 0 to the length of the first array in the bindings.

[[i x] xs
:range [0 10]]

The bindings also support :let, which works like a regular `let` in
the inner loop. In the typed namespaces, it casts to the array
type (for speedy math), e.g.

[x xs
:let [alpha 5 delta (- x 9)]]
<expression involving x, alpha, delta>

Be aware that `:let` explicitly disallows shadowing the array
bindings, e. g. `(afill! [myvar xs :let [myvar 5]] myvar)` throws
an `IllegalArgumentException`. Do also note that destructuring
syntax is not supported.
raw docstring

afill!cljmacro

(afill! type bindings form)

Like amap, but writes the output of form to the first bound array and returns it.

Like `amap`, but writes the output of form to the first bound array
and returns it.
sourceraw docstring

amakecljmacro

(amake type [idx len] expr)

Make a new array of length len and element type type and fill it with values computed by expr.

Make a new array of length len and element type type and fill it
with values computed by expr.
sourceraw docstring

amapcljmacro

(amap type bindings form)

Like for, but with hiphip-style array bindings. Builds a new array with element-type type from values produced by form at each step, with length equal to the range of the iteration.

Like for, but with hiphip-style array bindings.  Builds a new array
with element-type type from values produced by form at each step,
with length equal to the range of the iteration.
sourceraw docstring

areducecljmacro

(areduce bindings ret init form)

Areduce, with hiphip-style array bindings.

Note: The type of the accumulator will have the same semantics as those of a variable in a loop.

Areduce, with hiphip-style array bindings.

Note: The type of the accumulator will have the same semantics as
those of a variable in a loop.
sourceraw docstring

doarrcljmacro

(doarr bindings & body)

Like doseq, but with hiphip-style array bindings.

Like doseq, but with hiphip-style array bindings.
sourceraw docstring

make-arraycljmacro

(make-array type len)

Like Clojure's make-array, but type must be a compile-time literal, correctly type-hints the output array, and primitives can be specified like 'double' in addition to Double/TYPE

Like Clojure's make-array, but type must be a compile-time literal,
correctly type-hints the output array, and primitives can be specified
like 'double' in addition to Double/TYPE
sourceraw docstring

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

× close