Liking cljdoc? Tell your friends :D

tesser.utils

Toolbox.

Toolbox.
raw docstring

appendclj

(append coll element)

Appends a single value to the end of a sequence. O(1); uses conj for vectors, concat for other seqs.

Appends a single value to the end of a sequence. O(1); uses conj for
vectors, concat for other seqs.
sourceraw docstring

chunk-arrayclj

(chunk-array chunk-size ary)

Partitions an array into reducibles of size chunk-size (like chunk), but faster.

Partitions an array into reducibles of size `chunk-size` (like
chunk), but faster.
sourceraw docstring

chunk-vecclj

(chunk-vec n v)

Partitions a vector into reducibles of size n (somewhat like partition-all) but uses subvec for speed.

(chunk-vec 2 [1])     ; => ([1])
(chunk-vec 2 [1 2 3]) ; => ([1 2] [3])

Useful for supplying vectors to tesser.core/tesser.

Partitions a vector into reducibles of size n (somewhat like partition-all)
but uses subvec for speed.

    (chunk-vec 2 [1])     ; => ([1])
    (chunk-vec 2 [1 2 3]) ; => ([1 2] [3])

Useful for supplying vectors to tesser.core/tesser.
sourceraw docstring

complete-triangular-matrixclj

(complete-triangular-matrix m)

Given a map of [x y] keys to values, returns a map where both [x y] and [y x] point to identical values. Useful for pairwise comparisons which compute triangular matrices but want to return a full matrix.

Given a map of `[x y]` keys to values, returns a map where *both* `[x y]`
and `[y x]` point to identical values. Useful for pairwise comparisons which
compute triangular matrices but want to return a full matrix.
sourceraw docstring

cumulative-sumsclj

(cumulative-sums coll)
(cumulative-sums init coll)

A seq of the cumulative sums of all elements in coll, starting at init or the first element of coll if init is not provided. If differences provides differentials, cumulative-sums provides integrals.

(cumulative-sums 1 [1 2 1 -3])
; (1 2 4 5 2)
A seq of the cumulative sums of all elements in `coll`, starting at `init`
or the first element of `coll` if `init` is not provided. If `differences`
provides differentials, `cumulative-sums` provides integrals.

    (cumulative-sums 1 [1 2 1 -3])
    ; (1 2 4 5 2)
sourceraw docstring

def-type-predicatecljmacro

(def-type-predicate name exemplar)

Takes an instance of an object and defines a function that tests an object to see if its class is an instance of the exemplar's.

Takes an instance of an object and defines a function that tests an object
to see if its class is an instance of the exemplar's.
sourceraw docstring

differencesclj

(differences coll)

A seq of the differences between successive elements in a collection. For example,

(differences [1 2 4 5 2])
; (1 2 1 -3)
A seq of the differences between successive elements in a collection. For
example,

    (differences [1 2 4 5 2])
    ; (1 2 1 -3)
sourceraw docstring

doubles?clj

(doubles? x__1270__auto__)
source

first-non-nil-reducerclj

(first-non-nil-reducer _ x)

A reducing function that simply returns the first non-nil element in the collection.

A reducing function that simply returns the first non-nil element in the
collection.
sourceraw docstring

floats?clj

(floats? x__1270__auto__)
source

index-byclj

(index-by f xs)

Given an indexing function f and a collection of xs, return a map of (f x) -> x.

Given an indexing function f and a collection of xs, return a map of (f x)
-> x.
sourceraw docstring

ints?clj

(ints? x__1270__auto__)
source

longs?clj

(longs? x__1270__auto__)
source

map-valsclj

(map-vals f m)

Maps over a key-value map, returning a new map by transforming each value with (f v).

Maps over a key-value map, returning a new map by transforming each value
with (f v).
sourceraw docstring

maybe-unaryclj

(maybe-unary f)

Not all functions used in tesser/fold and tesser/reduce have a single-arity form. This takes a function f and returns a fn g such that (g x) is (f x) unless (f x) throws ArityException, in which case (g x) returns just x.

Not all functions used in `tesser/fold` and `tesser/reduce` have a
single-arity form. This takes a function `f` and returns a fn `g` such that
`(g x)` is `(f x)` unless `(f x)` throws ArityException, in which case `(g
x)` returns just `x`.
sourceraw docstring

objects?clj

(objects? x__1270__auto__)
source

Paircljprotocol

aclj

(a pair)

Returns the first element in the Pair.

Returns the first element in the Pair.

bclj

(b pair)

Returns the second element in the Pair.

Returns the second element in the Pair.

set-a!clj

(set-a! pair a')

Set the first element in the Pair.

Set the first element in the Pair.

set-b!clj

(set-b! pair b')

Set the second element in the Pair.

Set the second element in the Pair.

set-both!clj

(set-both! pair a' b')

Set both the first and second element in the pair.

Set both the first and second element in the pair.
source

path-fnclj

(path-fn path)

Takes a path for get-in and converts it to a function that operates on associative structures.

Takes a path for get-in and converts it to a function that operates on
associative structures.
sourceraw docstring

prependclj

(prepend coll element)

Prepends a single value to the beginning of a sequence. O(1) for sequences using cons, O(n) for vectors. Returns a singleton vector when coll is nil.

Prepends a single value to the beginning of a sequence. O(1) for sequences
using cons, O(n) for vectors. Returns a singleton vector when coll is nil.
sourceraw docstring

reduce-firstclj

(reduce-first reducible)

clojure.core/first, but for for reducibles.

clojure.core/first, but for for reducibles.
sourceraw docstring

reducible-chunkclj

(reducible-chunk n coll)

Like partition-all, but only emits reducibles. Faster for vectors and arrays. May return chunks of any reducible type. Useful for supplying colls to tesser.

(->> [1 2 3 4 5 6 7 8]
     (chunk 2)
     (map (partial into [])))
; => ([1 2] [3 4] [5 6] [7 8])
Like partition-all, but only emits reducibles. Faster for vectors and
arrays. May return chunks of any reducible type. Useful for supplying colls
to tesser.

    (->> [1 2 3 4 5 6 7 8]
         (chunk 2)
         (map (partial into [])))
    ; => ([1 2] [3 4] [5 6] [7 8])
sourceraw docstring

reducible-slicecljmacro

(reducible-slice getter coll length offset)

A reducible slice of an indexed collection. Expands into a reified CollReduce which uses (getter coll ... i) to return the ith element. Defined as a macro so we can do primitive agets, which are waaaay faster for arrays. Slice will have maximum length n, and starts at index i0.

A reducible slice of an indexed collection. Expands into a reified
CollReduce which uses `(getter coll ... i)` to return the `i`th element.
Defined as a macro so we can do primitive agets, which are waaaay faster for
arrays. Slice will have maximum length n, and starts at index i0.
sourceraw docstring

reducible-slice-bytesclj

(reducible-slice-bytes ary chunk-size offset)
source

reducible-slice-doublesclj

(reducible-slice-doubles ary chunk-size offset)
source

reducible-slice-floatsclj

(reducible-slice-floats ary chunk-size offset)
source

reducible-slice-intsclj

(reducible-slice-ints ary chunk-size offset)
source

reducible-slice-longsclj

(reducible-slice-longs ary chunk-size offset)
source

reducible-slice-objectsclj

(reducible-slice-objects ary chunk-size offset)
source

reducible-slice-shortsclj

(reducible-slice-shorts ary chunk-size offset)
source

scredcljmacro

(scred rfn-name expr)

Helper for short-circuiting nested reduction functions which can emit reduced values. Given the name of a function that could emit a reduced value, and an expression:

(scred rfn [1 (rfn x y)])

Expands to code that converts the expression to a reduced value whenever the underlying function emits a reduced value:

(let [acc (rfn x y)]
  (if (reduced? acc)
    (let [acc @acc] (reduced [1 acc]))
    [1 acc]))

scred does not interpret lexical scope, so don't rebind rfn in expr. Uses prewalk, so the outermost fn is where scred will cut out an expr. Keep this as simple as possible, haha.

Helper for short-circuiting nested reduction functions which can emit
reduced values. Given the name of a function that could emit a reduced
value, and an expression:

    (scred rfn [1 (rfn x y)])

Expands to code that converts the expression to a reduced value whenever
the underlying function emits a reduced value:

    (let [acc (rfn x y)]
      (if (reduced? acc)
        (let [acc @acc] (reduced [1 acc]))
        [1 acc]))

scred does not interpret lexical scope, so don't rebind rfn in expr.
Uses prewalk, so the outermost fn is where scred will cut out an expr.
Keep this as simple as possible, haha.
sourceraw docstring

shorts?clj

(shorts? x__1270__auto__)
source

successive-pairsclj

(successive-pairs coll)
(successive-pairs prev coll)

A much faster version of (partition 2 1 coll) which generates vectors, not lazy seqs.

A much faster version of (partition 2 1 coll) which generates vectors, not
lazy seqs.
sourceraw docstring

unsafe-pairclj

(unsafe-pair)
(unsafe-pair a b)

Constructs a new unsynchronized mutable pair object, suitable for single-threaded mutation.

Constructs a new unsynchronized mutable pair object, suitable for
single-threaded mutation.
sourceraw docstring

var->symclj

(var->sym v)

Converts a var to fully qualified symbol.

Converts a var to fully qualified symbol.
sourceraw docstring

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

× close