(->UnsafePair a b)
Positional factory function for class tesser.utils.UnsafePair.
(append coll element)
Appends a single value to the end of a sequence. O(1); uses conj for vectors, concat for other seqs.
(chunk-array chunk-size ary)
Partitions an array into reducibles of size
chunk-size (like chunk), but faster.
(chunk-vec n v)
Partitions a vector into reducibles of size n (somewhat like partition-all) but uses subvec for speed.
(chunk-vec 2 ) ; => () (chunk-vec 2 [1 2 3]) ; => ([1 2] )
Useful for supplying vectors to tesser.core/tesser.
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.
(cumulative-sums init coll)
A seq of the cumulative sums of all elements in
coll, starting at
init or the first element of
init is not provided. If
differences provides differentials,
cumulative-sums provides integrals.
(cumulative-sums 1 [1 2 1 -3]) ; (1 2 4 5 2)
(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.
A seq of the differences between successive elements in a collection. For example,
(differences [1 2 4 5 2]) ; (1 2 1 -3)
(first-non-nil-reducer _ x)
A reducing function that simply returns the first non-nil element in the collection.
(index-by f xs)
Given an indexing function f and a collection of xs, return a map of (f x) -> x.
(map-vals f m)
Maps over a key-value map, returning a new map by transforming each value with (f v).
Not all functions used in
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
x) returns just
Returns the first element in the Pair.
Returns the second element in the Pair.
(set-a! pair a')
Set the first element in the Pair.
(set-b! pair b')
Set the second element in the Pair.
(set-both! pair a' b')
Set both the first and second element in the pair.
Takes a path for get-in and converts it to a function that operates on associative structures.
(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.
clojure.core/first, but for for reducibles.
(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])
(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.
(reducible-slice-bytes ary chunk-size offset)
(reducible-slice-doubles ary chunk-size offset)
(reducible-slice-floats ary chunk-size offset)
(reducible-slice-ints ary chunk-size offset)
(reducible-slice-longs ary chunk-size offset)
(reducible-slice-objects ary chunk-size offset)
(reducible-slice-shorts ary chunk-size offset)
(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.
(successive-pairs prev coll)
A much faster version of (partition 2 1 coll) which generates vectors, not lazy seqs.
(unsafe-pair a b)
Constructs a new unsynchronized mutable pair object, suitable for single-threaded mutation.
Converts a var to fully qualified symbol.