Tanguv0.32.0
/iter/set/map/sorted-map/unordered-map/circular-buffer/vec/func

Collections & iteration

Lazy iterator combinators (/iter), sets (/set), sorted and unordered maps, vectors (/vec), and ring buffers.

Module /iter #

Lazy iterator adapters and eager sequence reductions (map, filter, fold, reduce, zip, take, drop, chunk, flatten, group-by, partition).

(use /iter)

Iter #

(arr)

Exported function in /iter.

all? #

(xs f)

Exported function in /iter.

any? #

(xs f)

Exported function in /iter.

chunks #

(Func [Array Int] Array)

Exported function in /iter.

compact #

(xs)

Exported function in /iter.

drop #

(iter/drop coll n) -> List

Returns collection excluding first n items.

(iter/drop [1 2 3 4] 2) ; -> [3 4]

filter #

(iter/filter coll predicate) -> List

Returns elements of collection for which predicate returns true.

(iter/filter [1 2 3 4] (Func [x] (== (% x 2) 0))) ; -> [2 4]

filter-unique #

(iter/filter-unique coll) -> Array

Deduplicates elements of collection in O(N) time while preserving first-seen insertion order.

(use {filter-unique} /iter)
(filter-unique ["b" "a" "b" "c"]) ; -> ["b" "a" "c"]

filter-unique-by #

(iter/filter-unique-by coll key-fn) -> Array

Deduplicates elements of collection by (key-fn item) in O(N) time while preserving first-seen insertion order.

(use {filter-unique-by} /iter)
(filter-unique-by users (Func [u] u:id))

find #

(iter/find coll predicate) -> (Or Any)

Returns the first element satisfying predicate, or () if none found.

(iter/find [1 2 3] (Func [x] (> x 1))) ; -> 2

find-index #

(Func [Array Func] Any)

Exported function in /iter.

flat-map #

(xs func)

Exported function in /iter.

flatten #

(xs)

Exported function in /iter.

fold #

(iter/fold coll init func) -> Any

Folds collection left-to-right with accumulator and reducer function.

(iter/fold [1 2 3] 0 (Func [acc x] (+ acc x))) ; -> 6

group-by #

(Func [Any Any] Map)

Exported function in /iter.

map #

(iter/map coll func) -> List

Applies function to each item in collection, returning a new List of results.

(iter/map [1 2 3] (Func [x] (* x 2))) ; -> [2 4 6]

next #

(it)

Exported function in /iter.

partition #

(Func [Array Func] Array)

Exported function in /iter.

reduce #

(Func [Array Func] Any)

Exported function in /iter.

rewind #

(it step)

Exported function in /iter.

take #

(iter/take coll n) -> List

Returns first n items from collection.

(iter/take [1 2 3 4] 2) ; -> [1 2]

windows #

(Func [Array Int] Array)

Exported function in /iter.

Module /set #

Hash-based unordered set operations: union, intersection, difference, symmetric-difference, subset?, and superset?.

(use /set)

Set #

(Set) -> Set

Constructs a new empty Set or initializes a Set with the given items.

(use /set)
(let s (Set))
(put s "apple")

contains? #

(Func [Set Any] Any)

Exported function in /set.

count-of #

(Func Set Int)

Exported function in /set.

difference #

(Func Any Set)

Exported function in /set.

intersection #

(Func Any Set)

Exported function in /set.

into-iter #

(Func Set Any)

Exported function in /set.

put #

(put set item) -> Set

Inserts an element into the set.

remove #

(Func [Set Any] Any)

Exported function in /set.

subset? #

(Func [Set Set] Any)

Exported function in /set.

union #

(Func Any Set)

Exported function in /set.

values-of #

(values-of set) -> Array

Returns an Array containing all elements in the set.

Module /map #

Map transformation helpers (pick, extend, union) complementing the prelude Map intrinsics.

(use /map)

extend #

(target source)

Exported function in /map.

pick #

(source keys)

Exported function in /map.

union #

(x y)

Exported function in /map.

Module /sorted-map #

B-Tree backed ordered map (Sorted-Map) maintaining keys in ascending sorted order.

(use /sorted-map)

Sorted-Map #

(Sorted-Map ...)

Exported function in /sorted-map.

contains-key? #

(contains-key? ...)

Exported function in /sorted-map.

count #

(count ...)

Exported function in /sorted-map.

count-of #

(count-of ...)

Exported function in /sorted-map.

entries-of #

(entries-of ...)

Exported function in /sorted-map.

first-entry #

(first-entry ...)

Exported function in /sorted-map.

get #

(get ...)

Exported function in /sorted-map.

into-iter #

(into-iter ...)

Exported function in /sorted-map.

is-empty? #

(is-empty? ...)

Exported function in /sorted-map.

keys-of #

(keys-of ...)

Exported function in /sorted-map.

last-entry #

(last-entry ...)

Exported function in /sorted-map.

put #

(put ...)

Exported function in /sorted-map.

remove #

(remove ...)

Exported function in /sorted-map.

values-of #

(values-of ...)

Exported function in /sorted-map.

Module /unordered-map #

Explicit hash map wrapper (Unordered-Map) with entry iteration and key/value views.

(use /unordered-map)

Unordered-Map #

(Unordered-Map ...)

Exported function in /unordered-map.

contains-key? #

(contains-key? ...)

Exported function in /unordered-map.

count #

(count ...)

Exported function in /unordered-map.

count-of #

(count-of ...)

Exported function in /unordered-map.

entries-of #

(entries-of ...)

Exported function in /unordered-map.

get #

(get ...)

Exported function in /unordered-map.

into-iter #

(into-iter ...)

Exported function in /unordered-map.

is-empty? #

(is-empty? ...)

Exported function in /unordered-map.

keys-of #

(keys-of ...)

Exported function in /unordered-map.

put #

(put ...)

Exported function in /unordered-map.

remove #

(remove ...)

Exported function in /unordered-map.

values-of #

(values-of ...)

Exported function in /unordered-map.

Module /circular-buffer #

Fixed-capacity ring buffer (Circular-Buffer) supporting O(1) push/pop and sequence iteration.

(use /circular-buffer)

Circular-Buffer #

(Circular-Buffer ...)

Exported function in /circular-buffer.

Iter #

(Iter ...)

Exported function in /circular-buffer.

as-array #

(as-array ...)

Exported function in /circular-buffer.

count-of #

(count-of ...)

Exported function in /circular-buffer.

into-iter #

(into-iter ...)

Exported function in /circular-buffer.

push #

(push ...)

Exported function in /circular-buffer.

put #

(put ...)

Exported function in /circular-buffer.

Module /vec #

2D, 3D, and 4D Euclidean vector math (Vec2, Vec3, Vec4): dot product, cross product, normalization, and distance.

(use /vec)

Vec2 #

Struct in /vec

2D vector with #Float components.

Field Type Default
x Float —
y Float —

Vec3 #

Struct in /vec

3D vector with #Float components.

Field Type Default
x Float —
y Float —
z Float —

Vec4 #

Struct in /vec

4D homogeneous vector with #Float components.

Field Type Default
x Float —
y Float —
z Float —
field_7 Any —

Vec #

Trait in /vec

Algebraic vector trait for N-dimensional #Float Structs. Automatically implemented via (derive T Vec).

cross #

(a b)

Computes the 3D cross product in homogeneous 4D coordinates (t = 0.0).

perp #

(v)

Returns the 2D perpendicular vector (-y, x) (90-degree counterclockwise rotation).

Module /func #

Higher-order function utilities including partial application (curry), dynamic argument invocation (apply), and memoization (memoize).

(use /func)

apply #

(Func [Any (Array Any)] Any)

Exported function in /func.

curry #

(Func Any Any)

Exported function in /func.

memoize #

(Func Any Any)

Exported function in /func.