Liking cljdoc? Tell your friends :D

brokvolli.core

Vars used from other namespaces, plus helper functions.

Vars used from other namespaces, plus helper functions.
raw docstring

*keydex*clj

Within a transducer stack modified by kv-ize, dynamically bound to the "current" key/index while being invoked with single/transduce-kv and multi/transduce-kv. Do not manually re-bind.

Within a transducer stack modified by [[kv-ize]], dynamically bound to the
"current" key/index while being invoked with [[single/transduce-kv]] and
[[multi/transduce-kv]]. Do not manually re-bind.
raw docstring

concatvclj

(concatv)
(concatv v)
(concatv v1 v2)

Concatenates vectors v1 and v2 eagerly and efficiently.

See benchmarking and analysis.

Examples:

(concatv) ;; => []
(concatv [11 22 33]) ;; => [11 22 33]
(concatv [11 22 33] [44 55 66]) ;; => [11 22 33 44 55 66]
Concatenates vectors `v1` and `v2` eagerly and efficiently.

See [benchmarking and analysis](https://blosavio.github.io/brokvolli/concat_performance.html).

Examples:
```
(concatv) ;; => []
(concatv [11 22 33]) ;; => [11 22 33]
(concatv [11 22 33] [44 55 66]) ;; => [11 22 33 44 55 66]
```
raw docstring

kv-izeclj

(kv-ize composition)

Given a composition of transducing functions (a transducing stack) that only provides arities zero, one, and two, returns an equivalent transducer stack that also accepts result, key/index, and value, suitable for use with both transduce-kv variants, single/transduce-kv and multi/transduce-kv.

Intended for exploratory work or when the transducer stack is pre-composed. Otherwise, prefer composing transducer stacks with brokvolli.transducers-kv and brokvolli.stateful-transducers-kv.

The returned composition provides two additional capabilities.

  1. Diverts the key/index provided by transduce-kv, passing only the accumulated value and the next element to the outer/top transducer, and
  2. Establishes a binding context where the key/index is available by referencing *keydex* from any layer of the transducer stack.

Example, a transducer stack, out of our control:

(def xf-from-somewhere (comp (map inc)
                             (filter even?)
                             (take 3)))

(transduce-kv (kv-ize xf-from-somewhere) conj [11 22 33 44 55 66 77 88 99])
;; => [12 34 56]

Example, using clojure.core/filter instead of [[filter-kv]], key/index accessible through dynamic var *keydex*:

(transduce-kv (kv-ize (filter (fn [_] (<= *keydex* 2)))) conj [11 22 33 44 55])
;; => [11 22 33]
Given a `composition` of transducing functions (a transducing stack) that
only provides arities zero, one, and two, returns an equivalent transducer
stack that also accepts *result*, *key/index*, and *value*, suitable for use
with both `transduce-kv` variants, [[single/transduce-kv]] and
[[multi/transduce-kv]].

Intended for exploratory work or when the transducer stack is pre-composed.
Otherwise, prefer composing transducer stacks with
[[brokvolli.transducers-kv]] and [[brokvolli.stateful-transducers-kv]].

The returned composition provides two additional capabilities.

1. Diverts the key/index provided by `transduce-kv`, passing only the
accumulated value and the next element to the outer/top transducer, and
2. Establishes a binding context where the key/index is available by
referencing [[*keydex*]] from any layer of the transducer stack.

Example, a transducer stack, out of our control:
```clojure
(def xf-from-somewhere (comp (map inc)
                             (filter even?)
                             (take 3)))

(transduce-kv (kv-ize xf-from-somewhere) conj [11 22 33 44 55 66 77 88 99])
;; => [12 34 56]
```

Example, using `clojure.core/filter` instead of [[filter-kv]], key/index
accessible through dynamic var [[*keydex*]]:
```clojure
(transduce-kv (kv-ize (filter (fn [_] (<= *keydex* 2)))) conj [11 22 33 44 55])
;; => [11 22 33]
```
raw docstring

tassocclj

(tassoc)
(tassoc x)
(tassoc x y)
(tassoc x y z)

An assoc variant, useful as the reducing function in a transduce operation.

  • With no args, returns {}.
  • With one arg, returns arg.
  • With two args, associates y to *keydex* within x.
  • With three args, associates y to z within x.

See also tconj for a similar utility used in transducing over sequential collections.

Example:

(transduce-kv (map-kv (fn [keydex x] {:keydex (inc keydex) :value x})) tassoc [11 22 33])
;; => {0 {:keydex 1, :value 11}
;;     1 {:keydex 2, :value 22}
;;     2 {:keydex 3, :value 33}}
An [assoc](https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/assoc)
variant, useful as the reducing function in a `transduce` operation.

* With no args, returns `{}`.
* With one arg, returns arg.
* With two args, associates `y` to [[*keydex*]] within `x`.
* With three args, associates `y` to `z` within `x`.

See also [[tconj]] for a similar utility used in transducing over sequential
collections.

Example:
```clojure
(transduce-kv (map-kv (fn [keydex x] {:keydex (inc keydex) :value x})) tassoc [11 22 33])
;; => {0 {:keydex 1, :value 11}
;;     1 {:keydex 2, :value 22}
;;     2 {:keydex 3, :value 33}}
```
raw docstring

tconjclj

(tconj)
(tconj x)
(tconj x y)
(tconj x _ z)

A conj variant, useful as the reducing function in a transduce operation.

  • With no args, returns [].
  • With one arg, returns arg.
  • With two args, conjoins y onto x.
  • With three args, conjoins z onto x, ignoring the second arg (which is typically the key/index).

See also tassoc for a similar utility used in transducing over associative collections.

Example:

(transduce-kv (map-kv (fn [keydex x] [keydex x])) tconj [11 22 33])
;; => [[0 11] [1 22] [2 33]]
A [conj](https://clojure.github.io/clojure/clojure.core-api.html#clojure.core/conj)
variant, useful as the reducing function in a `transduce` operation.

* With no args, returns `[]`.
* With one arg, returns arg.
* With two args, conjoins `y` onto `x`.
* With three args, conjoins `z` onto `x`, ignoring the second arg (which is
typically the key/index).

See also [[tassoc]] for a similar utility used in transducing over associative
collections.

Example:
```clojure
(transduce-kv (map-kv (fn [keydex x] [keydex x])) tconj [11 22 33])
;; => [[0 11] [1 22] [2 33]]
```
raw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close