HQL Standard Library

314 documented stdlib functions across sequences, predicates, math, maps, strings, and more.

Core Runtime Functions

not

(not value)

Returns false for truthy values and true for falsy values.

Arity: 1 · Return: false for truthy values and true for falsy values · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: assert, str

(not false)
;=> true

source →

assert

(assert condition ...message)

Throws when condition is falsy. Returns nil when the assertion passes.

Arity: 1+ · Return: Throws when condition is falsy · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: not, str, contains?

No verified inline example: the interesting failure path is an intentional thrown error.

source →

str

(str ...args)

Concatenates the string representation of all arguments. nil renders as an empty string.

Arity: 0+ · Return: Concatenates the string representation of all arguments · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: not, assert, contains?, xor

(str "a" 1 nil "b")
;=> "a1b"

source →

contains?

(contains? coll key)

Returns true when coll contains key: Set/Map membership, array/string index, or object own key.

Arity: 2 · Return: true when coll contains key: Set/Map membership, array/string index, or object own key · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: assert, str, xor, print

(contains? [10 20 30] 1)
;=> true

source →

xor

(xor a b)

Returns b when a is falsy, otherwise the logical negation of b.

Arity: 2 · Return: b when a is falsy, otherwise the logical negation of b · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: str, contains?, print, add-tap

(xor true false)
;=> true

source →

print

(print ...args)

Prints arguments WITHOUT a trailing newline where the host has a raw sink (hql_print_writer or Deno stdout); browser hosts fall back to console.log. Typed print options delegate to a host formatter.

Arity: 0+ · Return: Prints arguments WITHOUT a trailing newline where the host has a raw sink (hql_print_writer or Deno stdout); browser hosts fall back to console.log · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: contains?, xor, add-tap, remove-tap

No verified inline example: writes to stdout and would pollute the example verifier output.

source →

add-tap

(add-tap f)

Adds f to the tap> notification set and returns nil.

Arity: 1 · Return: Adds f to the tap> notification set and returns nil · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: xor, print, remove-tap, tap>

No verified inline example: mutates process-local tap subscribers.

source →

remove-tap

(remove-tap f)

Removes f from the tap> notification set and returns nil.

Arity: 1 · Return: Removes f from the tap> notification set and returns nil · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: print, add-tap, tap>, println

No verified inline example: mutates process-local tap subscribers.

source →

tap>

(tap> x)

Sends x to every registered tap function and returns true.

Arity: 1 · Return: Sends x to every registered tap function and returns true · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: add-tap, remove-tap, println

No verified inline example: depends on process-local tap subscribers.

source →

println

(println ...args)

Prints arguments followed by a newline.

Arity: 0+ · Return: Prints arguments followed by a newline · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: remove-tap, tap>

No verified inline example: writes to stdout and would pollute the example verifier output.

source →

Sequence Primitives

take

(take n ...args)

Returns a lazy sequence of the first n items from coll. With only n, returns the take transducer.

Arity: 1+ · Return: a lazy sequence of the first n items from coll · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: drop, map

(take 2 [1 2 3 4])
;=> (1 2)

source →

drop

(drop n ...args)

Returns a lazy sequence of all but the first n items from coll. With only n, returns the drop transducer.

Arity: 1+ · Return: a lazy sequence of all but the first n items from coll · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: take, map, filter

(drop 2 [1 2 3 4])
;=> (3 4)

source →

map

(map f ...colls)

Returns a lazy sequence consisting of (f x) for each x in coll. With only f, returns the map transducer.

Arity: 1+ · Return: a lazy sequence consisting of (f x) for each x in coll · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: take, drop, filter, reduce

(map (fn [x] (* x x)) [1 2 3])
;=> (1 4 9)

source →

filter

(filter pred ...args)

Returns a lazy sequence of items from coll for which (pred item) is truthy. With only pred, returns the filter transducer.

Arity: 1+ · Return: a lazy sequence of items from coll for which (pred item) is truthy · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: drop, map, reduce, reduce-kv

(filter odd? [1 2 3 4 5])
;=> (1 3 5)

source →

reduce

(reduce f ...args)

Reduces coll with f, optionally starting from init. Honors (reduced x) for early termination.

Arity: 1+ · Return: Reduces coll with f, optionally starting from init · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: map, filter, reduce-kv, concat

(reduce + [1 2 3 4])
;=> 10

source →

reduce-kv

(reduce-kv f init coll ...extra)

Reduces a map-like collection as (f acc key value) or a vector as (f acc index value). Honors (reduced x).

Arity: 3+ · Return: Reduces a map-like collection as (f acc key value) or a vector as (f acc index value) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: filter, reduce, concat, list*

(reduce-kv (fn [acc k v] (+ acc v)) 0 {:a 1 :b 2})
;=> 3

source →

concat

(concat ...colls)

Returns a lazy sequence concatenating the items of all collections.

Arity: 0+ · Return: a lazy sequence concatenating the items of all collections · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: reduce, reduce-kv, list*, flatten

(concat [1 2] [3 4])
;=> (1 2 3 4)

source →

list*

(list* x ...more)

Returns a seq made by consing leading args onto the final seqable arg.

Arity: 1+ · Return: a seq made by consing leading args onto the final seqable arg · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: reduce-kv, concat, flatten, tree-seq

(list* 1 2 [3 4])
;=> (1 2 3 4)

source →

flatten

(flatten coll)

Recursively flattens nested iterables into a single lazy sequence. Strings are treated as scalars.

Arity: 1 · Return: Recursively flattens nested iterables into a single lazy sequence · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: concat, list*, tree-seq, distinct

(flatten [1 [2 [3 4]]])
;=> (1 2 3 4)

source →

tree-seq

(tree-seq branch? children root ...extra)

Returns a lazy preorder traversal of root, descending through (children node) when (branch? node) is truthy.

Arity: 3+ · Return: a lazy preorder traversal of root, descending through (children node) when (branch? node) is truthy · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: list*, flatten, distinct, next

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

distinct

(distinct ...args)

Returns a lazy sequence of unique items from coll, preserving order. With no args, returns the distinct transducer.

Arity: 0+ · Return: a lazy sequence of unique items from coll, preserving order · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: flatten, tree-seq, next, nth

(distinct [1 1 2 3 3])
;=> (1 2 3)

source →

next

(next coll)

Returns a seq of the items after the first, or nil when there are none.

Arity: 1 · Return: a seq of the items after the first, or nil when there are none · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: tree-seq, distinct, nth, second

(next [1 2 3])
;=> (2 3)

source →

nth

(nth coll index ...args)

Returns the item at index i. Throws on out-of-bounds unless not-found is provided.

Arity: 2+ · Return: the item at index i · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: distinct, next, second, count

(nth [10 20 30] 1)
;=> 20

source →

second

(second coll)

Returns the second item of coll, or nil.

Arity: 1 · Return: the second item of coll, or nil · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: next, nth, count, last

(second [1 2 3])
;=> 2

source →

count

(count coll)

Returns the number of items in coll. O(1) for arrays, strings, Set/Map, plain objects, and counted seqs; O(n) otherwise.

Arity: 1 · Return: the number of items in coll · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: nth, second, last, first

(count [1 2 3])
;=> 3

source →

last

(last coll)

Returns the last item of coll, or nil for empty colls.

Arity: 1 · Return: the last item of coll, or nil for empty colls · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: second, count, first, rest

(last [1 2 3])
;=> 3

source →

first

(first coll)

Returns the first item of coll, or nil for an empty/nil collection.

Arity: 1 · Return: the first item of coll, or nil for an empty/nil collection · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: count, last, rest, cons

(first [1 2 3])
;=> 1

source →

rest

(rest coll)

Returns a sequence of all items after the first. Empty/nil collections return an empty sequence.

Arity: 1 · Return: a sequence of all items after the first · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: last, first, cons, seq

(rest [1 2 3])
;=> (2 3)

source →

cons

(cons x coll)

Returns a sequence with x prepended to coll.

Arity: 2 · Return: a sequence with x prepended to coll · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: first, rest, seq, range

(cons 0 [1 2])
;=> (0 1 2)

source →

seq

(seq coll)

Returns a sequence over coll, or nil when coll is nil or empty.

Arity: 1 · Return: a sequence over coll, or nil when coll is nil or empty · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: rest, cons, range

(seq [1 2 3])
;=> (1 2 3)

source →

range

(range start end step)

Returns a lazy numeric range. With no args, starts at 0; with one arg, returns 0 through end-1; with start/end/step, returns that stepped range.

Arity: 3 · Return: a lazy numeric range · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: cons, seq

(range 5)
;=> (0 1 2 3 4)

source →

Sequence Operations

map-indexed

(map-indexed f coll)

Returns a lazy sequence of (f index item) over coll.

Arity: 2 · Return: a lazy sequence of (f index item) over coll · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: keep-indexed, mapcat

(map-indexed (fn [i x] [i x]) ["a" "b"])
;=> ([0 "a"] [1 "b"])

source →

keep-indexed

(keep-indexed f coll)

Like map-indexed but drops nil results. Returns a lazy sequence.

Arity: 2 · Return: Like map-indexed but drops nil results · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: map-indexed, mapcat, keep

(keep-indexed (fn [i x] (if (odd? i) x nil)) [10 20 30 40])
;=> (20 40)

source →

mapcat

(mapcat f ...colls)

Returns a lazy concatenation of mapped collections. With only f, returns the mapcat transducer.

Arity: 1+ · Return: a lazy concatenation of mapped collections · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: map-indexed, keep-indexed, keep, take-while

(mapcat (fn [x] [x x]) [1 2])
;=> (1 1 2 2)

source →

keep

(keep f ...args)

Returns non-nil results of (f item) over coll. With only f, returns the keep transducer.

Arity: 1+ · Return: non-nil results of (f item) over coll · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: keep-indexed, mapcat, take-while, drop-while

(keep (fn [x] (if (odd? x) x nil)) [1 2 3 4])
;=> (1 3)

source →

take-while

(take-while pred ...args)

Returns a lazy sequence of items from coll while (pred item) is truthy. With only pred, returns the take-while transducer.

Arity: 1+ · Return: a lazy sequence of items from coll while (pred item) is truthy · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: mapcat, keep, drop-while, split-with

(take-while (fn [x] (< x 3)) [1 2 3 4 1])
;=> (1 2)

source →

drop-while

(drop-while pred ...args)

Returns a lazy sequence of items from coll starting at the first one where (pred item) is falsy. With only pred, returns the drop-while transducer.

Arity: 1+ · Return: a lazy sequence of items from coll starting at the first one where (pred item) is falsy · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: keep, take-while, split-with, split-at

(drop-while (fn [x] (< x 3)) [1 2 3 4 1])
;=> (3 4 1)

source →

split-with

(split-with pred coll)

Returns [(take-while pred coll), (drop-while pred coll)] as a tuple of two realized arrays.

Arity: 2 · Return: [(take-while pred coll), (drop-while pred coll)] as a tuple of two realized arrays · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: take-while, drop-while, split-at, nthrest

(split-with (fn [x] (< x 3)) [1 2 3 4])
;=> [[1, 2], [3, 4]]

source →

split-at

(split-at n coll)

Returns [(take n coll), (drop n coll)] as a tuple of two realized arrays.

Arity: 2 · Return: [(take n coll), (drop n coll)] as a tuple of two realized arrays · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: drop-while, split-with, nthrest, nthnext

(split-at 2 [1 2 3 4])
;=> [[1, 2], [3, 4]]

source →

nthrest

(nthrest coll n)

Returns the seq after dropping n items from coll; returns nil for nil input.

Arity: 2 · Return: the seq after dropping n items from coll; returns nil for nil input · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: split-with, split-at, nthnext, splitv-at

(nthrest [1 2 3 4 5] 2)
;=> (3 4 5)

source →

nthnext

(nthnext coll n)

Returns (seq (nthrest coll n)), or nil when no items remain.

Arity: 2 · Return: (seq (nthrest coll n)), or nil when no items remain · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: split-at, nthrest, splitv-at, take-nth

(nthnext [1 2 3 4 5] 2)
;=> (3 4 5)

source →

splitv-at

(splitv-at n coll)

Returns a persistent vector of two persistent vectors: (take n coll) and (drop n coll).

Arity: 2 · Return: a persistent vector of two persistent vectors: (take n coll) and (drop n coll) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: nthrest, nthnext, take-nth, reductions

(splitv-at 2 [1 2 3 4])
;=> [[1 2] [3 4]]

source →

take-nth

(take-nth n coll)

Returns a lazy sequence of every nth item from coll.

Arity: 2 · Return: a lazy sequence of every nth item from coll · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: nthnext, splitv-at, reductions, interpose

(take-nth 2 [1 2 3 4 5 6])
;=> (1 3 5)

source →

reductions

(reductions f ...args)

Returns a lazy sequence of intermediate values from a reduce over coll. With an init: (reductions f init coll); without: uses the first element. (reductions + [1, 2, 3, 4]) ⇒ (1 3 6 10).

Arity: 1+ · Return: a lazy sequence of intermediate values from a reduce over coll · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: splitv-at, take-nth, interpose, interleave

(reductions + [1 2 3 4])
;=> (1 3 6 10)

source →

interpose

(interpose sep coll)

Returns a lazy sequence of coll with sep placed between each pair of elements. (interpose "x" [1, 2, 3]) ⇒ (1 "x" 2 "x" 3).

Arity: 2 · Return: a lazy sequence of coll with sep placed between each pair of elements · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: take-nth, reductions, interleave, partition

(interpose "x" [1 2 3])
;=> (1 "x" 2 "x" 3)

source →

interleave

(interleave ...colls)

Returns a lazy sequence of the first item in each coll, then the second, etc. (interleave [1, 2, 3] ["a", "b", "c"]) ⇒ (1 "a" 2 "b" 3 "c").

Arity: 0+ · Return: a lazy sequence of the first item in each coll, then the second, etc · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: reductions, interpose, partition, partition-all

(interleave [1 2 3] ["a" "b" "c"])
;=> (1 "a" 2 "b" 3 "c")

source →

partition

(partition n ...args)

Returns lazy chunks of n items from coll. Supports (partition n coll), (partition n step coll), and (partition n step pad coll).

Arity: 1+ · Return: lazy chunks of n items from coll · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: interpose, interleave, partition-all, partitionv

(partition 2 [1 2 3 4 5])
;=> ([1, 2] [3, 4])

source →

partition-all

(partition-all n ...args)

Like partition but keeps the trailing incomplete group. With only n, returns the partition-all transducer.

Arity: 1+ · Return: Like partition but keeps the trailing incomplete group · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: interleave, partition, partitionv, partitionv-all

(partition-all 2 [1 2 3 4 5])
;=> ([1, 2] [3, 4] [5])

source →

partitionv

(partitionv n ...args)

Like partition, but each emitted group is a persistent vector.

Arity: 1+ · Return: Like partition, but each emitted group is a persistent vector · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: partition, partition-all, partitionv-all, partition-by

(partitionv 2 [1 2 3 4])
;=> ([1 2] [3 4])

source →

partitionv-all

(partitionv-all n ...args)

Like partition-all, but each emitted group is a persistent vector.

Arity: 1+ · Return: Like partition-all, but each emitted group is a persistent vector · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: partition-all, partitionv, partition-by, drop-last

(partitionv-all 2 [1 2 3 4 5])
;=> ([1 2] [3 4] [5])

source →

partition-by

(partition-by f coll)

Returns a lazy sequence of runs from coll, splitting whenever (f item) changes.

Arity: 2 · Return: a lazy sequence of runs from coll, splitting whenever (f item) changes · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: partitionv, partitionv-all, drop-last, take-last

(partition-by odd? [1 1 2 2 3])
;=> ([1, 1] [2, 2] [3])

source →

drop-last

(drop-last ...args)

Returns a seq of all but the last n items of coll; n defaults to 1.

Arity: 0+ · Return: a seq of all but the last n items of coll; n defaults to 1 · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: partitionv-all, partition-by, take-last, butlast

(drop-last [1 2 3])
;=> (1 2)

source →

take-last

(take-last n coll)

Returns a seq of the last n items of coll.

Arity: 2 · Return: a seq of the last n items of coll · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: partition-by, drop-last, butlast, ffirst

(take-last 2 [1 2 3 4])
;=> (3 4)

source →

butlast

(butlast coll)

Returns a seq of all but the last item of coll, or nil when there are fewer than two items.

Arity: 1 · Return: a seq of all but the last item of coll, or nil when there are fewer than two items · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: drop-last, take-last, ffirst, fnext

(butlast [1 2 3])
;=> (1 2)

source →

ffirst

(ffirst coll)

Equivalent to (first (first coll)).

Arity: 1 · Return: Equivalent to (first (first coll)) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: take-last, butlast, fnext, nfirst

(ffirst [[1 2] [3 4]])
;=> 1

source →

fnext

(fnext coll)

Equivalent to (first (next coll)).

Arity: 1 · Return: Equivalent to (first (next coll)) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: butlast, ffirst, nfirst, nnext

(fnext [1 2 3])
;=> 2

source →

nfirst

(nfirst coll)

Equivalent to (next (first coll)).

Arity: 1 · Return: Equivalent to (next (first coll)) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: ffirst, fnext, nnext

(nfirst [[1 2 3] [4]])
;=> (2 3)

source →

nnext

(nnext coll)

Equivalent to (next (next coll)).

Arity: 1 · Return: Equivalent to (next (next coll)) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: fnext, nfirst

(nnext [1 2 3 4])
;=> (3 4)

source →

Predicates

empty?

(empty? coll)

Returns true when coll has no items.

Arity: 1 · Return: true when coll has no items · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: some, every?

(empty? [])
;=> true

source →

some

(some pred coll)

Returns the first truthy (pred item) result from coll, or nil if none. Short-circuits.

Arity: 2 · Return: the first truthy (pred item) result from coll, or nil if none · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: empty?, every?, not-any?

(some odd? [2 4 5])
;=> true

source →

every?

(every? pred coll)

Returns true when (pred item) is truthy for every item in coll. Empty collection returns true (vacuous). Short-circuits on first falsy.

Arity: 2 · Return: true when (pred item) is truthy for every item in coll · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: empty?, some, not-any?, not-every?

(every? odd? [1 3 5])
;=> true

source →

not-any?

(not-any? pred coll)

Returns true when (pred item) is falsy for every item in coll. The complement of some.

Arity: 2 · Return: true when (pred item) is falsy for every item in coll · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: some, every?, not-every?, some?

(not-any? odd? [2 4 6])
;=> true

source →

not-every?

(not-every? pred coll)

Returns true when at least one item in coll makes (pred item) falsy. The complement of every.

Arity: 2 · Return: true when at least one item in coll makes (pred item) falsy · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: every?, not-any?, some?, any?

(not-every? odd? [1 2 3])
;=> true

source →

some?

(some? x)

Returns true when x is neither null nor undefined (0, false, "" all qualify as some).

Arity: 1 · Return: true when x is neither null nor undefined (0, false, "" all qualify as some) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: not-any?, not-every?, any?, boolean

(some? nil)
;=> false

source →

any?

(any? x)

Returns true for any value, including nil.

Arity: 1 · Return: true for any value, including nil · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: not-every?, some?, boolean, associative?

(any? nil)
;=> true

source →

boolean

(boolean x)

Returns false only for nil and false; true for every other value.

Arity: 1 · Return: false only for nil and false; true for every other value · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: some?, any?, associative?, coll?

(boolean 0)
;=> true

source →

associative?

(associative? x)

Returns true for map-like and vector-like collections.

Arity: 1 · Return: true for map-like and vector-like collections · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: any?, boolean, coll?, counted?

(associative? {:a 1})
;=> true

source →

coll?

(coll? x)

Returns true for HQL and JS collection values, excluding nil and strings.

Arity: 1 · Return: true for HQL and JS collection values, excluding nil and strings · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: boolean, associative?, counted?, seq?

(coll? [1 2])
;=> true

source →

counted?

(counted? x)

Returns true when count can be answered without walking a seq.

Arity: 1 · Return: true when count can be answered without walking a seq · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: associative?, coll?, seq?, seqable?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

seq?

(seq? x)

Returns true when x is an HQL seq value.

Arity: 1 · Return: true when x is an HQL seq value · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: coll?, counted?, seqable?, sequential?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

seqable?

(seqable? x)

Returns true when x can be passed to seq.

Arity: 1 · Return: true when x can be passed to seq · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: counted?, seq?, sequential?, nil?

(seqable? "ab")
;=> true

source →

sequential?

(sequential? x)

Returns true for list/vector/seq-like collections.

Arity: 1 · Return: true for list/vector/seq-like collections · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: seq?, seqable?, nil?, null?

(sequential? [1 2])
;=> true

source →

nil?

(nil? x)

Returns true when x is null or undefined.

Arity: 1 · Return: true when x is null or undefined · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: seqable?, sequential?, null?, undefined?

(nil? nil)
;=> true

source →

null?

(null? x)

Returns true when x is exactly null.

Arity: 1 · Return: true when x is exactly null · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: sequential?, nil?, undefined?, defined?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

undefined?

(undefined? x)

Returns true when x is exactly undefined.

Arity: 1 · Return: true when x is exactly undefined · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: nil?, null?, defined?, even?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

defined?

(defined? x)

Returns true when x is not undefined.

Arity: 1 · Return: true when x is not undefined · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: null?, undefined?, even?, odd?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

even?

(even? n)

Returns true when n is an even integer.

Arity: 1 · Return: true when n is an even integer · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: undefined?, defined?, odd?, zero?

(even? 4)
;=> true

source →

odd?

(odd? n)

Returns true when n is an odd integer.

Arity: 1 · Return: true when n is an odd integer · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: defined?, even?, zero?, pos?

(odd? 3)
;=> true

source →

zero?

(zero? n)

Returns true when n equals 0.

Arity: 1 · Return: true when n equals 0 · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: even?, odd?, pos?, neg?

(zero? 0)
;=> true

source →

pos?

(pos? n)

Returns true when n > 0.

Arity: 1 · Return: true when n > 0 · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: odd?, zero?, neg?, NaN?

(pos? 3)
;=> true

source →

neg?

(neg? n)

Returns true when n < 0.

Arity: 1 · Return: true when n < 0 · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: zero?, pos?, NaN?, infinite?

(neg? -2)
;=> true

source →

NaN?

(NaN? x)

Returns true when x is the JavaScript NaN value.

Arity: 1 · Return: true when x is the JavaScript NaN value · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: pos?, neg?, infinite?, inst?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

infinite?

(infinite? x)

Returns true when x is positive or negative infinity.

Arity: 1 · Return: true when x is positive or negative infinity · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: neg?, NaN?, inst?, inst-ms

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

inst?

(inst? x)

Returns true when x is a JavaScript Date.

Arity: 1 · Return: true when x is a JavaScript Date · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: NaN?, infinite?, inst-ms, instance?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

inst-ms

(inst-ms x)

Returns the epoch millisecond value of a Date.

Arity: 1 · Return: the epoch millisecond value of a Date · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: infinite?, inst?, instance?, uri?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

instance?

(instance? cls x)

Returns true when x is an instance of constructor cls.

Arity: 2 · Return: true when x is an instance of constructor cls · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: inst?, inst-ms, uri?, number?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

uri?

(uri? x)

Returns true when x is a JavaScript URL.

Arity: 1 · Return: true when x is a JavaScript URL · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: inst-ms, instance?, number?, string?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

number?

(number? x)

Returns true when x is a number.

Arity: 1 · Return: true when x is a number · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: instance?, uri?, string?, boolean?

(number? 42)
;=> true

source →

string?

(string? x)

Returns true when x is a string.

Arity: 1 · Return: true when x is a string · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: uri?, number?, boolean?, fn?

(string? "x")
;=> true

source →

boolean?

(boolean? x)

Returns true when x is a boolean.

Arity: 1 · Return: true when x is a boolean · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: number?, string?, fn?, ifn?

(boolean? true)
;=> true

source →

fn?

(fn? x)

Returns true when x is a function.

Arity: 1 · Return: true when x is a function · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: string?, boolean?, ifn?, array?

(fn? inc)
;=> true

source →

ifn?

(ifn? x)

Returns true for values HQL can invoke directly as a function call.

Arity: 1 · Return: true for values HQL can invoke directly as a function call · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: boolean?, fn?, array?, indexed?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

array?

(array? x)

Returns true when x is a JavaScript array.

Arity: 1 · Return: true when x is a JavaScript array · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: fn?, ifn?, indexed?, object?

(array? [1, 2])
;=> true

source →

indexed?

(indexed? x)

Returns true for collections addressable by integer index in O(1).

Arity: 1 · Return: true for collections addressable by integer index in O(1) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: ifn?, array?, object?, array

(indexed? [1 2 3])
;=> true

source →

object?

(object? x)

Returns true when x is a plain object (not nil, not an array).

Arity: 1 · Return: true when x is a plain object (not nil, not an array) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: array?, indexed?, array, vector

(object? {a: 1})
;=> true

source →

array

(array ...items)

Returns a fresh JavaScript array containing items.

Arity: 0+ · Return: a fresh JavaScript array containing items · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: indexed?, object?, vector, persistent-map

(array 1 2 3)
;=> [1, 2, 3]

source →

vector

(vector ...items)

Returns an immutable HQL persistent vector with structural updates.

Arity: 0+ · Return: an immutable HQL persistent vector with structural updates · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: object?, array, persistent-map, array-map

(vector 1 2 3)
;=> [1 2 3]

source →

persistent-map

(persistent-map ...entries)

Returns an immutable persistent map. Keys compare by structural value, not JS object identity.

Arity: 0+ · Return: an immutable persistent map · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: array, vector, array-map, persistent-set

(persistent-map :a 1 :b 2)
;=> {:a 1 :b 2}

source →

array-map

(array-map ...entries)

Returns a persistent map from alternating key/value arguments.

Arity: 0+ · Return: a persistent map from alternating key/value arguments · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: vector, persistent-map, persistent-set, persistent-vector?

(array-map :a 1 :b 2)
;=> {:a 1 :b 2}

source →

persistent-set

(persistent-set ...items)

Returns an immutable persistent set. Values compare by structural value, not JS object identity.

Arity: 0+ · Return: an immutable persistent set · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: persistent-map, array-map, persistent-vector?, persistent-map?

(persistent-set 1 2 2 3)
;=> #[2 3 1]

source →

persistent-vector?

(persistent-vector? x)

Returns true when x is an HQL persistent vector.

Arity: 1 · Return: true when x is an HQL persistent vector · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: array-map, persistent-set, persistent-map?, persistent-set?

(persistent-vector? [1 2 3])
;=> true

source →

persistent-map?

(persistent-map? x)

Returns true when x is an HQL persistent map.

Arity: 1 · Return: true when x is an HQL persistent map · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: persistent-set, persistent-vector?, persistent-set?, map-entry?

(persistent-map? {:a 1})
;=> true

source →

persistent-set?

(persistent-set? x)

Returns true when x is an HQL persistent set.

Arity: 1 · Return: true when x is an HQL persistent set · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: persistent-vector?, persistent-map?, map-entry?, to-js

(persistent-set? #[1 2])
;=> true

source →

map-entry?

(map-entry? x)

Returns true for HQL map-entry shaped key/value pairs.

Arity: 1 · Return: true for HQL map-entry shaped key/value pairs · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: persistent-map?, persistent-set?, to-js, from-js

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

to-js

(to-js x)

Recursively converts HQL persistent collections to plain JavaScript arrays, objects, Maps, and Sets.

Arity: 1 · Return: Recursively converts HQL persistent collections to plain JavaScript arrays, objects, Maps, and Sets · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: persistent-set?, map-entry?, from-js, delay?

(to-js [1 2 3])
;=> [1, 2, 3]

source →

from-js

(from-js x)

Recursively converts JavaScript arrays and plain objects/Maps to HQL persistent collections.

Arity: 1 · Return: Recursively converts JavaScript arrays and plain objects/Maps to HQL persistent collections · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: map-entry?, to-js, delay?, force

(from-js [1, 2, 3])
;=> [1 2 3]

source →

delay?

(delay? x)

Returns true when x is a Delay returned by the delay macro.

Arity: 1 · Return: true when x is a Delay returned by the delay macro · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: to-js, from-js, force, realized?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

force

(force x)

Forces evaluation of a Delay x (memoized). Returns non-Delay values unchanged.

Arity: 1 · Return: Forces evaluation of a Delay x (memoized) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: from-js, delay?, realized?, reduced?

(force 42)
;=> 42

source →

realized?

(realized? coll)

Returns true when coll is nil, a forced Delay, or a realized LazySeq; false otherwise.

Arity: 1 · Return: true when coll is nil, a forced Delay, or a realized LazySeq; false otherwise · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: delay?, force, reduced?, ensure-reduced

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

reduced?

(reduced? x)

Returns true when x is a reduced marker.

Arity: 1 · Return: true when x is a reduced marker · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: force, realized?, ensure-reduced, unreduced

(reduced? (reduced 5))
;=> true

source →

ensure-reduced

(ensure-reduced x)

Returns x when it is already reduced, otherwise wraps it with reduced.

Arity: 1 · Return: x when it is already reduced, otherwise wraps it with reduced · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: realized?, reduced?, unreduced

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

unreduced

(unreduced x)

Returns the value inside a reduced marker, or x unchanged when it is not reduced.

Arity: 1 · Return: the value inside a reduced marker, or x unchanged when it is not reduced · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: reduced?, ensure-reduced

(unreduced (reduced 5))
;=> 5

source →

Math & Comparison

inc

(inc x)

Returns x + 1.

Arity: 1 · Return: x + 1 · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: dec, abs

(inc 5)
;=> 6

source →

dec

(dec x)

Returns x - 1.

Arity: 1 · Return: x - 1 · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: inc, abs, add

(dec 5)
;=> 4

source →

abs

(abs x)

Returns the absolute value of x.

Arity: 1 · Return: the absolute value of x · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: inc, dec, add, sub

(abs -7)
;=> 7

source →

add

(add ...nums)

Variadic addition. (add) ⇒ 0; (add x) ⇒ x; (add a b c ...) sums all args.

Arity: 0+ · Return: Variadic addition · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: dec, abs, sub, mul

(add 1 2 3)
;=> 6

source →

sub

(sub ...nums)

Variadic subtraction. (sub) ⇒ 0; (sub x) ⇒ -x; (sub a b c ...) is a - b - c - ....

Arity: 0+ · Return: Variadic subtraction · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: abs, add, mul, div

(sub 10 3 2)
;=> 5

source →

mul

(mul ...nums)

Variadic multiplication. (mul) ⇒ 1; (mul x) ⇒ x; (mul a b c ...) multiplies all.

Arity: 0+ · Return: Variadic multiplication · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: add, sub, div, mod

(mul 2 3 4)
;=> 24

source →

div

(div ...nums)

Variadic division. (div) ⇒ 1; (div x) ⇒ 1/x; (div a b c ...) is a / b / c / ....

Arity: 0+ · Return: Variadic division · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: sub, mul, mod, quot

(div 100 5 2)
;=> 10

source →

mod

(mod a b)

Returns a modulo b, floored so the result takes the sign of the divisor b (mathematical modulo). (mod -7 3) ⇒ 2; (mod 7 -3) ⇒ -2. Use % for truncated remainder.

Arity: 2 · Return: a modulo b, floored so the result takes the sign of the divisor b (mathematical modulo) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: mul, div, quot, rem

(mod -7 3)
;=> 2

source →

quot

(quot a b)

Returns the integer quotient of a / b, truncated toward zero.

Arity: 2 · Return: the integer quotient of a / b, truncated toward zero · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: div, mod, rem, bit-and

(quot 7 2)
;=> 3

source →

rem

(rem a b)

Returns the remainder of a / b with the sign of a.

Arity: 2 · Return: the remainder of a / b with the sign of a · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: mod, quot, bit-and, bit-or

(rem -7 3)
;=> -1

source →

bit-and

(bit-and x y ...more)

Returns the bitwise AND of two or more numbers using HQL's JavaScript integer bit semantics.

Arity: 2+ · Return: the bitwise AND of two or more numbers using HQL's JavaScript integer bit semantics · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: quot, rem, bit-or, bit-xor

(bit-and 6 3)
;=> 2

source →

bit-or

(bit-or x y ...more)

Returns the bitwise OR of two or more numbers using HQL's JavaScript integer bit semantics.

Arity: 2+ · Return: the bitwise OR of two or more numbers using HQL's JavaScript integer bit semantics · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: rem, bit-and, bit-xor, bit-not

(bit-or 6 3)
;=> 7

source →

bit-xor

(bit-xor x y ...more)

Returns the bitwise XOR of two or more numbers using HQL's JavaScript integer bit semantics.

Arity: 2+ · Return: the bitwise XOR of two or more numbers using HQL's JavaScript integer bit semantics · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-and, bit-or, bit-not, bit-and-not

(bit-xor 6 3)
;=> 5

source →

bit-not

(bit-not x)

Returns the bitwise complement of x.

Arity: 1 · Return: the bitwise complement of x · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-or, bit-xor, bit-and-not, bit-clear

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

bit-and-not

(bit-and-not x y ...more)

Clears all bits from x that are set in the remaining arguments.

Arity: 2+ · Return: Clears all bits from x that are set in the remaining arguments · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-xor, bit-not, bit-clear, bit-flip

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

bit-clear

(bit-clear x n)

Returns x with bit n cleared.

Arity: 2 · Return: x with bit n cleared · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-not, bit-and-not, bit-flip, bit-set

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

bit-flip

(bit-flip x n)

Returns x with bit n flipped.

Arity: 2 · Return: x with bit n flipped · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-and-not, bit-clear, bit-set, bit-test

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

bit-set

(bit-set x n)

Returns x with bit n set.

Arity: 2 · Return: x with bit n set · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-clear, bit-flip, bit-test, bit-shift-left

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

bit-test

(bit-test x n)

Returns true when bit n is set in x.

Arity: 2 · Return: true when bit n is set in x · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-flip, bit-set, bit-shift-left, bit-shift-right

(bit-test 5 0)
;=> true

source →

bit-shift-left

(bit-shift-left x n)

Returns x shifted left by n bits.

Arity: 2 · Return: x shifted left by n bits · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-set, bit-test, bit-shift-right, unsigned-bit-shift-right

(bit-shift-left 1 4)
;=> 16

source →

bit-shift-right

(bit-shift-right x n)

Returns x shifted right by n bits, preserving sign.

Arity: 2 · Return: x shifted right by n bits, preserving sign · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-test, bit-shift-left, unsigned-bit-shift-right, rand

(bit-shift-right 16 2)
;=> 4

source →

unsigned-bit-shift-right

(unsigned-bit-shift-right x n)

Returns x shifted right by n bits, zero-filling from the left.

Arity: 2 · Return: x shifted right by n bits, zero-filling from the left · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bit-shift-left, bit-shift-right, rand, rand-int

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

rand

(rand ...args)

Returns a random floating-point number between 0 and 1, or between 0 and n.

Arity: 0+ · Return: a random floating-point number between 0 and 1, or between 0 and n · Evaluation: eager · Effects: nondeterministic · Host: portable stdlib · Throws: not documented as throwing

Related: bit-shift-right, unsigned-bit-shift-right, rand-int, rand-nth

No verified inline example: returns nondeterministic output.

source →

rand-int

(rand-int n)

Returns a random integer between 0 inclusive and n exclusive, truncated toward zero.

Arity: 1 · Return: a random integer between 0 inclusive and n exclusive, truncated toward zero · Evaluation: eager · Effects: nondeterministic · Host: portable stdlib · Throws: not documented as throwing

Related: unsigned-bit-shift-right, rand, rand-nth, random-sample

No verified inline example: returns nondeterministic output.

source →

rand-nth

(rand-nth coll)

Returns a random item from coll, or nil for nil.

Arity: 1 · Return: a random item from coll, or nil for nil · Evaluation: eager · Effects: nondeterministic · Host: portable stdlib · Throws: not documented as throwing

Related: rand, rand-int, random-sample, parse-boolean

No verified inline example: returns nondeterministic output.

source →

random-sample

(random-sample prob coll)

Returns a lazy seq of items from coll selected with probability prob.

Arity: 2 · Return: a lazy seq of items from coll selected with probability prob · Evaluation: eager · Effects: nondeterministic · Host: portable stdlib · Throws: not documented as throwing

Related: rand-int, rand-nth, parse-boolean, parse-long

No verified inline example: returns nondeterministic output.

source →

parse-boolean

(parse-boolean s)

Parses "true" to true, "false" to false, and returns nil otherwise.

Arity: 1 · Return: Parses "true" to true, "false" to false, and returns nil otherwise · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: rand-nth, random-sample, parse-long, parse-double

(parse-boolean "true")
;=> true

source →

parse-long

(parse-long s)

Parses a base-10 integer string, returning nil when the whole string is not an integer.

Arity: 1 · Return: Parses a base-10 integer string, returning nil when the whole string is not an integer · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: random-sample, parse-boolean, parse-double, not=

(parse-long "42")
;=> 42

source →

parse-double

(parse-double s)

Parses a floating-point string, returning nil when the whole string is not a number.

Arity: 1 · Return: Parses a floating-point string, returning nil when the whole string is not a number · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: parse-boolean, parse-long, not=, compare

(parse-double "3.14")
;=> 3.14

source →

not=

(not= x ...more)

Returns true when not all arguments are structurally equal.

Arity: 1+ · Return: true when not all arguments are structurally equal · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: parse-long, parse-double, compare, comparator

(not= 1 2)
;=> true

source →

compare

(compare a b)

Returns -1, 0, or 1 using Clojure-style ordering for nil, comparable scalar values, keywords, symbols, UUIDs, and vectors.

Arity: 2 · Return: -1, 0, or 1 using Clojure-style ordering for nil, comparable scalar values, keywords, symbols, UUIDs, and vectors · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: parse-double, not=, comparator, sorted?

(compare 1 2)
;=> -1

source →

comparator

(comparator pred)

Returns a comparator from a binary predicate.

Arity: 1 · Return: a comparator from a binary predicate · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: not=, compare, sorted?, sorted-map-by

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

sorted?

(sorted? coll)

Returns true when coll is an HQL sorted map or sorted set.

Arity: 1 · Return: true when coll is an HQL sorted map or sorted set · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: compare, comparator, sorted-map-by, sorted-map

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

sorted-map-by

(sorted-map-by cmp ...kvs)

Returns an HQL sorted map ordered by comparator cmp.

Arity: 1+ · Return: an HQL sorted map ordered by comparator cmp · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: comparator, sorted?, sorted-map, sorted-set-by

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

sorted-map

(sorted-map ...kvs)

Returns an HQL sorted map ordered by compare.

Arity: 0+ · Return: an HQL sorted map ordered by compare · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: sorted?, sorted-map-by, sorted-set-by, sorted-set

(sorted-map :b 2 :a 1)
;=> {:a 1 :b 2}

source →

sorted-set-by

(sorted-set-by cmp ...items)

Returns an HQL sorted set ordered by comparator cmp.

Arity: 1+ · Return: an HQL sorted set ordered by comparator cmp · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: sorted-map-by, sorted-map, sorted-set, subseq

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

sorted-set

(sorted-set ...items)

Returns an HQL sorted set ordered by compare.

Arity: 0+ · Return: an HQL sorted set ordered by compare · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: sorted-map, sorted-set-by, subseq, rsubseq

(sorted-set 3 1 2)
;=> #[1 2 3]

source →

subseq

(subseq coll test key ...args)

Returns a seq of sorted collection items satisfying the supplied bound(s).

Arity: 3+ · Return: a seq of sorted collection items satisfying the supplied bound(s) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: sorted-set-by, sorted-set, rsubseq, lt

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

rsubseq

(rsubseq coll test key ...args)

Returns a reverse seq of sorted collection items satisfying the supplied bound(s).

Arity: 3+ · Return: a reverse seq of sorted collection items satisfying the supplied bound(s) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: sorted-set, subseq, lt, gt

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

lt

(lt ...nums)

Variadic less-than. (lt a b c) means a < b < c.

Arity: 0+ · Return: Variadic less-than · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: subseq, rsubseq, gt, lte

(lt 1 2 3)
;=> true

source →

gt

(gt ...nums)

Variadic greater-than. (gt a b c) means a > b > c.

Arity: 0+ · Return: Variadic greater-than · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: rsubseq, lt, lte, gte

(gt 3 2 1)
;=> true

source →

lte

(lte ...nums)

Variadic less-than-or-equal. (lte a b c) means a <= b <= c.

Arity: 0+ · Return: Variadic less-than-or-equal · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: lt, gt, gte

(lte 1 1 2)
;=> true

source →

gte

(gte ...nums)

Variadic greater-than-or-equal. (gte a b c) means a >= b >= c.

Arity: 0+ · Return: Variadic greater-than-or-equal · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: gt, lte

(gte 3 3 1)
;=> true

source →

Symbols & Generators

symbol

(symbol n ...args)

Constructs an HQL symbol object from name, or from namespace and name.

Arity: 1+ · Return: Constructs an HQL symbol object from name, or from namespace and name · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: gensym, keyword

(symbol "foo")
;=> foo

source →

gensym

(gensym ...args)

Returns a fresh HQL symbol. (gensym) uses the G__ prefix; (gensym prefix) stringifies prefix.

Arity: 0+ · Return: a fresh HQL symbol · Evaluation: eager · Effects: nondeterministic · Host: portable stdlib · Throws: not documented as throwing

Related: symbol, keyword, find-keyword

No verified inline example: returns a fresh generated symbol.

source →

keyword

(keyword n ...args)

Constructs an interned HQL keyword value from name, or from namespace and name.

Arity: 1+ · Return: Constructs an interned HQL keyword value from name, or from namespace and name · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: symbol, gensym, find-keyword, parse-uuid

(keyword "foo")
;=> :foo

source →

find-keyword

(find-keyword n ...args)

Returns an already-interned HQL keyword for name or namespace/name, or nil.

Arity: 1+ · Return: an already-interned HQL keyword for name or namespace/name, or nil · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: gensym, keyword, parse-uuid, random-uuid

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

parse-uuid

(parse-uuid s)

Parses a UUID string into an HQL UUID value, or nil when parsing fails.

Arity: 1 · Return: Parses a UUID string into an HQL UUID value, or nil when parsing fails · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: keyword, find-keyword, random-uuid, uuid?

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

random-uuid

(random-uuid)

Returns a pseudo-random v4 HQL UUID value.

Arity: 0 · Return: a pseudo-random v4 HQL UUID value · Evaluation: eager · Effects: nondeterministic · Host: portable stdlib · Throws: not documented as throwing

Related: find-keyword, parse-uuid, uuid?, name

No verified inline example: returns nondeterministic output.

source →

uuid?

(uuid? x)

Returns true when x is an HQL UUID value.

Arity: 1 · Return: true when x is an HQL UUID value · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: parse-uuid, random-uuid, name, pr-str

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

name

(name x)

Returns the name part of a symbol or keyword; returns strings unchanged and nil for nil.

Arity: 1 · Return: the name part of a symbol or keyword; returns strings unchanged and nil for nil · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: random-uuid, uuid?, pr-str, hash

(name :foo)
;=> "foo"

source →

pr-str

(pr-str x)

Returns a readable HQL data string. Parenthesized code lists print space-separated; JS arrays/maps keep comma/colon syntax, persistent collections print HQL persistent syntax.

Arity: 1 · Return: a readable HQL data string · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: uuid?, name, hash, read-string

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

hash

(hash x)

Returns a deterministic structural hash code for HQL values.

Arity: 1 · Return: a deterministic structural hash code for HQL values · Evaluation: eager · Effects: nondeterministic · Host: portable stdlib · Throws: not documented as throwing

Related: name, pr-str, read-string, print-str

No verified inline example: hash values are implementation details rather than tutorial output.

source →

read-string

(read-string s)

Reads one canonical HQL data value from string s, producing the same S-expression object shape as quote.

Arity: 1 · Return: Reads one canonical HQL data value from string s, producing the same S-expression object shape as quote · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: pr-str, hash, print-str, println-str

(read-string "[1 2 3]")
;=> [1 2 3]

source →

(print-str ...xs)

Returns the space-separated str rendering of xs.

Arity: 0+ · Return: the space-separated str rendering of xs · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: hash, read-string, println-str, prn-str

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

println-str

(println-str ...xs)

Returns (print-str ...xs) followed by a newline.

Arity: 0+ · Return: (print-str ...xs) followed by a newline · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: read-string, print-str, prn-str, pr

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

prn-str

(prn-str ...xs)

Returns the space-separated pr-str rendering of xs followed by a newline.

Arity: 0+ · Return: the space-separated pr-str rendering of xs followed by a newline · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: print-str, println-str, pr, prn

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

pr

(pr ...xs)

Prints the pr-str rendering of xs without a trailing newline and returns nil.

Arity: 0+ · Return: Prints the pr-str rendering of xs without a trailing newline and returns nil · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: println-str, prn-str, prn, ex-info

No verified inline example: prints to stdout and returns nil.

source →

prn

(prn ...xs)

Prints the pr-str rendering of xs followed by a newline and returns nil.

Arity: 0+ · Return: Prints the pr-str rendering of xs followed by a newline and returns nil · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: prn-str, pr, ex-info, ex-message

No verified inline example: prints to stdout and returns nil.

source →

ex-info

(ex-info message data ...args)

Returns an Error carrying message, data, and optional cause.

Arity: 2+ · Return: an Error carrying message, data, and optional cause · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: pr, prn, ex-message, ex-data

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

ex-message

(ex-message err)

Returns the message from an exception value.

Arity: 1 · Return: the message from an exception value · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: prn, ex-info, ex-data, ex-cause

(ex-message (ex-info "boom" {:code 1}))
;=> "boom"

source →

ex-data

(ex-data err)

Returns data attached by ex-info, or nil when absent.

Arity: 1 · Return: data attached by ex-info, or nil when absent · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: ex-info, ex-message, ex-cause, repeat

(ex-data (ex-info "boom" {:code 1}))
;=> {:code 1}

source →

ex-cause

(ex-cause err)

Returns the cause attached by ex-info, or nil when absent.

Arity: 1 · Return: the cause attached by ex-info, or nil when absent · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: ex-message, ex-data, repeat, replicate

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

repeat

(repeat ...args)

Returns a lazy sequence of repeated values. (repeat x) is infinite — bound it with take; (repeat n x) yields n copies of x.

Arity: 0+ · Return: a lazy sequence of repeated values · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: ex-data, ex-cause, replicate, repeatedly

(repeat 3 "x")
;=> ("x" "x" "x")

source →

replicate

(replicate n x)

Returns a lazy sequence of n copies of x.

Arity: 2 · Return: a lazy sequence of n copies of x · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: ex-cause, repeat, repeatedly, cycle

(replicate 3 "x")
;=> ("x" "x" "x")

source →

repeatedly

(repeatedly ...args)

Returns a lazy sequence of (f) calls. (repeatedly f) is infinite; (repeatedly n f) yields n calls.

Arity: 0+ · Return: a lazy sequence of (f) calls · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: repeat, replicate, cycle, iterate

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

cycle

(cycle coll)

Returns a lazy infinite sequence that repeats coll over and over. Use (take n (cycle coll)) to bound.

Arity: 1 · Return: a lazy infinite sequence that repeats coll over and over · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: replicate, repeatedly, iterate, iteration

(take 5 (cycle [1 2]))
;=> (1 2 1 2 1)

source →

iterate

(iterate f x)

Returns the lazy infinite sequence x, (f x), (f (f x)), ....

Arity: 2 · Return: the lazy infinite sequence x, (f x), (f (f x)), ... · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: repeatedly, cycle, iteration

(take 4 (iterate (fn [x] (* x 2)) 1))
;=> (1 2 4 8)

source →

iteration

(iteration step ...args)

Returns a lazy sequence by repeatedly calling step with a continuation key. Options: :initk, :somef, :vf, :kf.

Arity: 1+ · Return: a lazy sequence by repeatedly calling step with a continuation key · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: cycle, iterate

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

Map Operations

keys

(keys obj)

Returns a seq of the keys of map/object m.

Arity: 1 · Return: a seq of the keys of map/object m · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: group-by, reverse

(keys {:a 1 :b 2})
;=> [:a, :b]

source →

group-by

(group-by f coll)

Returns a persistent map of (f item) -> vector of items.

Arity: 2 · Return: a persistent map of (f item) -> vector of items · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: keys, reverse, reversible?

(group-by odd? [1 2 3 4 5])
;=> {true [1 3 5] false [2 4]}

source →

reverse

(reverse coll)

Returns a sequence of coll in reverse order.

Arity: 1 · Return: a sequence of coll in reverse order · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: keys, group-by, reversible?, rseq

(reverse [1 2 3])
;=> [3, 2, 1]

source →

reversible?

(reversible? x)

Returns true when x supports efficient reverse sequence access.

Arity: 1 · Return: true when x supports efficient reverse sequence access · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: group-by, reverse, rseq, identity

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

rseq

(rseq coll)

Returns a reverse seq over a vector-like collection, or nil when it is empty.

Arity: 1 · Return: a reverse seq over a vector-like collection, or nil when it is empty · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: reverse, reversible?, identity, freeze

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

identity

(identity x)

Returns its argument unchanged. Useful as a default mapper or predicate.

Arity: 1 · Return: its argument unchanged · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: reversible?, rseq, freeze, constantly

(identity 42)
;=> 42

source →

freeze

(freeze x)

Recursively freezes x in place (deep Object.freeze) and returns the same reference; frozen collections reject mutation (throwing in strict mode). Lazy sequences, generators, and typed-array views are returned unfrozen because freezing would break their internal state. let already prevents rebinding a name — reach for freeze when you also need the value itself to be immutable.

Arity: 1 · Return: Recursively freezes x in place (deep Object.freeze) and returns the same reference; frozen collections reject mutation (throwing in strict mode) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: rseq, identity, constantly, vals

No verified inline example: the observable result is object identity and immutability, not a useful printed value.

source →

constantly

(constantly x)

Returns a function that ignores its arguments and always returns x.

Arity: 1 · Return: a function that ignores its arguments and always returns x · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: identity, freeze, vals, key

((constantly 7) 1 2 3)
;=> 7

source →

vals

(vals m)

Returns a seq of the values of map/object m.

Arity: 1 · Return: a seq of the values of map/object m · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: freeze, constantly, key, val

(vals {:a 1 :b 2})
;=> [1, 2]

source →

key

(key entry)

Returns the key from a map entry.

Arity: 1 · Return: the key from a map entry · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: constantly, vals, val, update-keys

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

val

(val entry)

Returns the value from a map entry.

Arity: 1 · Return: the value from a map entry · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: vals, key, update-keys, update-vals

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

update-keys

(update-keys m f)

Returns a map with every key transformed by f.

Arity: 2 · Return: a map with every key transformed by f · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: key, val, update-vals, juxt

(update-keys {:a 1 :b 2} name)
;=> {"b" 2 "a" 1}

source →

update-vals

(update-vals m f)

Returns a map with every value transformed by f.

Arity: 2 · Return: a map with every value transformed by f · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: val, update-keys, juxt, zipmap

(update-vals {:a 1 :b 2} inc)
;=> {:a 2 :b 3}

source →

juxt

(juxt ...fns)

Returns a function applying each fn in turn to its args. ((juxt f g h) x) returns [(f x), (g x), (h x)].

Arity: 0+ · Return: a function applying each fn in turn to its args · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: update-keys, update-vals, zipmap, get

((juxt first last) [1 2 3])
;=> [1 3]

source →

zipmap

(zipmap ks vs)

Returns a persistent map zipping each key in ks with the value at the same position in vs.

Arity: 2 · Return: a persistent map zipping each key in ks with the value at the same position in vs · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: update-vals, juxt, get, get-in

(zipmap [:a :b] [1 2])
;=> {:a 1 :b 2}

source →

get

(get m key ...args)

Looks up key in m. Returns not-found (or nil) when absent.

Arity: 2+ · Return: Looks up key in m · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: juxt, zipmap, get-in, assoc

(get {:a 1} :a)
;=> 1

source →

get-in

(get-in m path ...args)

Looks up a nested value by walking path (a vector of keys). Returns not-found (or nil) when any step is missing.

Arity: 2+ · Return: Looks up a nested value by walking path (a vector of keys) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: zipmap, get, assoc, assoc-in

(get-in {:a {:b 2}} [:a :b])
;=> 2

source →

assoc

(assoc m key value ...kvs)

Returns a new map/vector with key(s) set to value(s).

Arity: 3+ · Return: a new map/vector with key(s) set to value(s) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: get, get-in, assoc-in, dissoc

(assoc {:a 1} :b 2)
;=> {:a 1 :b 2}

source →

assoc-in

(assoc-in m path value)

Returns a new map with the nested value at path set to value. Intermediate maps are created as needed.

Arity: 3 · Return: a new map with the nested value at path set to value · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: get-in, assoc, dissoc, update

(assoc-in {:a {:b 1}} [:a :c] 9)
;=> {:a {:c 9 :b 1}}

source →

dissoc

(dissoc m ...ks)

Returns a new map with the given keys removed. Maps and plain objects only — arrays are rejected: deleting an index would leave a silent hole (count unchanged, undefined slot).

Arity: 1+ · Return: a new map with the given keys removed · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: assoc, assoc-in, update, update-in

(dissoc {:a 1 :b 2} :a)
;=> {:b 2}

source →

update

(update m key f ...args)

Returns a new map with key set to (f (get m key) ...args).

Arity: 3+ · Return: a new map with key set to (f (get m key) ...args) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: assoc-in, dissoc, update-in, find

(update {:n 1} :n inc)
;=> {:n 2}

source →

update-in

(update-in m path f)

Returns a new map with the nested value at path set to (f (get-in m path)).

Arity: 3 · Return: a new map with the nested value at path set to (f (get-in m path)) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: dissoc, update, find

(update-in {:a {:b 1}} [:a :b] inc)
;=> {:a {:b 2}}

source →

find

(find m key)

Returns [key value] when key is present in m, otherwise nil.

Arity: 2 · Return: [key value] when key is present in m, otherwise nil · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: update, update-in

(find {:a 1} :a)
;=> [:a 1]

source →

Managed State

atom

(atom initial)

Returns a synchronous mutable reference whose contained value is read with deref and changed with reset! or swap!.

Arity: 1 · Return: a synchronous mutable reference whose contained value is read with deref and changed with reset! or swap! · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: atom?, volatile!

No verified inline example: stateful cell/watch behavior needs multi-step mutation context and is covered by managed-state tests.

source →

atom?

(atom? x)

Returns true when x is an HQL atom.

Arity: 1 · Return: true when x is an HQL atom · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: atom, volatile!, volatile?

(atom? (atom 1))
;=> true

source →

volatile!

(volatile! initial)

Returns a mutable volatile reference whose value is read with deref and changed with vreset! or vswap!.

Arity: 1 · Return: a mutable volatile reference whose value is read with deref and changed with vreset! or vswap! · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: atom, atom?, volatile?, deref

No verified inline example: stateful cell/watch behavior needs multi-step mutation context and is covered by managed-state tests.

source →

volatile?

(volatile? x)

Returns true when x is a volatile reference.

Arity: 1 · Return: true when x is a volatile reference · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: atom?, volatile!, deref, vreset!

No verified inline example: stateful cell/watch behavior needs multi-step mutation context and is covered by managed-state tests.

source →

deref

(deref ref)

Returns the current value of an atom/volatile or the realized value of a delay/reduced marker.

Arity: 1 · Return: the current value of an atom/volatile or the realized value of a delay/reduced marker · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: volatile!, volatile?, vreset!, vswap!

(do (def slot (atom 7)) (deref slot))
;=> 7

source →

vreset!

(vreset! ref value)

Sets volatile ref to value and returns value.

Arity: 2 · Return: Sets volatile ref to value and returns value · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: volatile?, deref, vswap!, reset!

No verified inline example: stateful cell/watch behavior needs multi-step mutation context and is covered by managed-state tests.

source →

vswap!

(vswap! ref f ...args)

Sets volatile ref to (f (deref ref) ...args) and returns the new value.

Arity: 2+ · Return: Sets volatile ref to (f (deref ref) ...args) and returns the new value · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: deref, vreset!, reset!, swap!

(do (def vol (volatile! 1)) (vswap! vol inc) (deref vol))
;=> 2

source →

reset!

(reset! ref value)

Sets atom ref to value, notifies watches, and returns value.

Arity: 2 · Return: Sets atom ref to value, notifies watches, and returns value · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: vreset!, vswap!, swap!, reset-vals!

(do (def cell (atom 1)) (reset! cell 9) (deref cell))
;=> 9

source →

swap!

(swap! ref f ...args)

Sets atom ref to (f (deref ref) ...args) and returns the new value.

Arity: 2+ · Return: Sets atom ref to (f (deref ref) ...args) and returns the new value · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: vswap!, reset!, reset-vals!, swap-vals!

(do (def box (atom 1)) (swap! box inc) (deref box))
;=> 2

source →

reset-vals!

(reset-vals! ref value)

Sets atom ref to value and returns [old-value new-value].

Arity: 2 · Return: Sets atom ref to value and returns [old-value new-value] · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: reset!, swap!, swap-vals!, compare-and-set!

No verified inline example: stateful cell/watch behavior needs multi-step mutation context and is covered by managed-state tests.

source →

swap-vals!

(swap-vals! ref f ...args)

Sets atom ref to (f (deref ref) ...args) and returns [old-value new-value].

Arity: 2+ · Return: Sets atom ref to (f (deref ref) ...args) and returns [old-value new-value] · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: swap!, reset-vals!, compare-and-set!, add-watch

No verified inline example: stateful cell/watch behavior needs multi-step mutation context and is covered by managed-state tests.

source →

compare-and-set!

(compare-and-set! ref old-value new-value)

If atom ref currently contains old-value by identity, sets it to new-value and returns true; otherwise returns false.

Arity: 3 · Return: If atom ref currently contains old-value by identity, sets it to new-value and returns true; otherwise returns false · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: reset-vals!, swap-vals!, add-watch, remove-watch

No verified inline example: stateful cell/watch behavior needs multi-step mutation context and is covered by managed-state tests.

source →

add-watch

(add-watch ref key f)

Registers watch function f under key. Watches receive [key ref old-value new-value] after reset/swap.

Arity: 3 · Return: Registers watch function f under key · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: swap-vals!, compare-and-set!, remove-watch

No verified inline example: stateful cell/watch behavior needs multi-step mutation context and is covered by managed-state tests.

source →

remove-watch

(remove-watch ref key)

Removes the watch registered under key and returns ref.

Arity: 2 · Return: Removes the watch registered under key and returns ref · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: compare-and-set!, add-watch

No verified inline example: stateful cell/watch behavior needs multi-step mutation context and is covered by managed-state tests.

source →

Open Polymorphism

dispatch-key

(dispatch-key key)

Normalizes open-dispatch keys. Keywords become their printed :name; other keys stay unchanged.

Arity: 1 · Return: Normalizes open-dispatch keys · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: dispatch-type, multi

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

dispatch-type

(dispatch-type x)

Returns the default open-polymorphism dispatch key for x: :type/"type" when present, then constructor, then JavaScript typeof.

Arity: 1 · Return: the default open-polymorphism dispatch key for x: :type/"type" when present, then constructor, then JavaScript typeof · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: dispatch-key, multi, multi?

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

multi

(multi dispatch-fn)

Returns an open dispatcher function. Register handlers with method!; call it directly or with call-method.

Arity: 1 · Return: an open dispatcher function · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: dispatch-key, dispatch-type, multi?, method!

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

multi?

(multi? x)

Returns true when x is an HQL multi dispatcher.

Arity: 1 · Return: true when x is an HQL multi dispatcher · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: dispatch-type, multi, method!, call-method

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

method!

(method! m key f)

Registers f as the handler for dispatch key on multi dispatcher m and returns m.

Arity: 3 · Return: Registers f as the handler for dispatch key on multi dispatcher m and returns m · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: multi, multi?, call-method, get-method

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

call-method

(call-method m x ...args)

Calls the method registered for ((dispatch m) x), passing x and remaining args to the handler.

Arity: 2+ · Return: Calls the method registered for ((dispatch m) x), passing x and remaining args to the handler · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: multi?, method!, get-method, methods

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

get-method

(get-method m key)

Returns the best method registered for dispatch key, or nil.

Arity: 2 · Return: the best method registered for dispatch key, or nil · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: method!, call-method, methods, remove-method

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

methods

(methods m)

Returns a persistent map of dispatch keys to methods.

Arity: 1 · Return: a persistent map of dispatch keys to methods · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: call-method, get-method, remove-method, remove-all-methods

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

remove-method

(remove-method m key)

Removes the method registered for dispatch key and returns the dispatcher.

Arity: 2 · Return: Removes the method registered for dispatch key and returns the dispatcher · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: get-method, methods, remove-all-methods, prefer-method

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

remove-all-methods

(remove-all-methods m)

Removes all methods from dispatcher m and returns it.

Arity: 1 · Return: Removes all methods from dispatcher m and returns it · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: methods, remove-method, prefer-method, prefers

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

prefer-method

(prefer-method m x y)

Records that dispatch x is preferred over y and returns the dispatcher.

Arity: 3 · Return: Records that dispatch x is preferred over y and returns the dispatcher · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: remove-method, remove-all-methods, prefers, make-hierarchy

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

prefers

(prefers m)

Returns a persistent map of dispatch preferences.

Arity: 1 · Return: a persistent map of dispatch preferences · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: remove-all-methods, prefer-method, make-hierarchy, derive

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

make-hierarchy

(make-hierarchy)

Returns a fresh HQL hierarchy value.

Arity: 0 · Return: a fresh HQL hierarchy value · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: prefer-method, prefers, derive, underive

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

derive

(derive h-or-tag tag-or-parent ...args)

Adds a parent relation to a hierarchy. With two args, updates HQL's global hierarchy.

Arity: 2+ · Return: Adds a parent relation to a hierarchy · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: prefers, make-hierarchy, underive, parents

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

underive

(underive h-or-tag tag-or-parent ...args)

Removes a parent relation from a hierarchy. With two args, updates HQL's global hierarchy.

Arity: 2+ · Return: Removes a parent relation from a hierarchy · Evaluation: eager · Effects: stateful · Host: portable stdlib · Throws: not documented as throwing

Related: make-hierarchy, derive, parents, ancestors

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

parents

(parents h-or-tag ...args)

Returns the direct parents of a tag in a hierarchy.

Arity: 1+ · Return: the direct parents of a tag in a hierarchy · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: derive, underive, ancestors, descendants

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

ancestors

(ancestors h-or-tag ...args)

Returns all ancestors of a tag in a hierarchy.

Arity: 1+ · Return: all ancestors of a tag in a hierarchy · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: underive, parents, descendants, supers

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

descendants

(descendants h-or-tag ...args)

Returns all descendants of a tag in a hierarchy.

Arity: 1+ · Return: all descendants of a tag in a hierarchy · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: parents, ancestors, supers, isa?

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

supers

(supers x)

Returns HQL hierarchy ancestors for x.

Arity: 1 · Return: HQL hierarchy ancestors for x · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: ancestors, descendants, isa?, merge

No verified inline example: open-polymorphism setup is multi-definition state and is covered in language examples/tests.

source →

isa?

(isa? h-or-child child-or-parent ...args)

Returns true when child equals or derives from parent in a hierarchy.

Arity: 2+ · Return: true when child equals or derives from parent in a hierarchy · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: descendants, supers, merge

(isa? 42 42)
;=> true

source →

merge

(merge ...maps)

Merges maps left-to-right. Later keys win.

Arity: 0+ · Return: Merges maps left-to-right · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: supers, isa?

(merge {:a 1} {:b 2})
;=> {:a 1 :b 2}

source →

Collection Builders

empty

(empty coll)

Returns an empty collection of the same type as coll (array, set, map, string, or object).

Arity: 1 · Return: an empty collection of the same type as coll (array, set, map, string, or object) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: conj, disj

(empty [1 2 3])
;=> []

source →

conj

(conj coll ...items)

Adds items to coll, returning a new collection of the same type.

Arity: 1+ · Return: Adds items to coll, returning a new collection of the same type · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: empty, disj, into

(conj [1 2] 3)
;=> [1 2 3]

source →

disj

(disj s ...items)

Returns a set with items removed.

Arity: 1+ · Return: a set with items removed · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: empty, conj, into, vec

(disj #[1 2 3] 2)
;=> #[3 1]

source →

into

(into ...args)

Pours items from from into to, returning the same type as to. (into to xform from) applies a transducer.

Arity: 0+ · Return: Pours items from from into to, returning the same type as to · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: conj, disj, vec, subvec

(into [1] [2 3])
;=> [1 2 3]

source →

vec

(vec coll)

Returns a persistent vector containing the items of coll.

Arity: 1 · Return: a persistent vector containing the items of coll · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: disj, into, subvec, set

(vec (range 3))
;=> [0 1 2]

source →

subvec

(subvec v start ...args)

Returns a persistent vector slice of v from start inclusive to end exclusive.

Arity: 2+ · Return: a persistent vector slice of v from start inclusive to end exclusive · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: into, vec, set, doall

(subvec [1 2 3 4 5] 1 3)
;=> [2 3]

source →

set

(set coll)

Returns a persistent set containing the unique items of coll.

Arity: 1 · Return: a persistent set containing the unique items of coll · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: vec, subvec, doall, dorun

(set [1 2 2 3])
;=> #[2 3 1]

source →

doall

(doall coll)

Forces realization of a lazy sequence into an array. Returns nil for nil.

Arity: 1 · Return: Forces realization of a lazy sequence into an array · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: subvec, set, dorun

(doall (map inc [1 2 3]))
;=> [2, 3, 4]

source →

dorun

(dorun ...args)

Forces realization for side effects and returns nil. (dorun n coll) realizes at most n items.

Arity: 0+ · Return: Forces realization for side effects and returns nil · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: set, doall

No verified inline example: runs a collection for side effects and intentionally returns nil.

source →

Higher-Order

comp

(comp ...fns)

Returns the composition of the given functions. ((comp f g) x) ≡ (f (g x)).

Arity: 0+ · Return: the composition of the given functions · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: partial, apply

((comp inc inc) 5)
;=> 7

source →

partial

(partial f ...args)

Returns a function that calls f with args prepended to its own arguments.

Arity: 1+ · Return: a function that calls f with args prepended to its own arguments · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: comp, apply, sort

((partial + 10) 5)
;=> 15

source →

apply

(apply f ...args)

Calls f with trailing collection items appended to any leading arguments.

Arity: 1+ · Return: Calls f with trailing collection items appended to any leading arguments · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: comp, partial, sort, sort-by

(apply + [1 2 3 4])
;=> 10

source →

sort

(sort ...args)

Returns coll sorted in ascending order. (sort cmp coll) uses a custom comparator.

Arity: 0+ · Return: coll sorted in ascending order · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: partial, apply, sort-by, shuffle

(sort [3 1 2])
;=> [1, 2, 3]

source →

sort-by

(sort-by keyfn ...args)

Returns coll sorted by (keyfn item). (sort-by keyfn cmp coll) uses a custom comparator on keys.

Arity: 1+ · Return: coll sorted by (keyfn item) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: apply, sort, shuffle, mapv

(sort-by count ["aa" "b" "ccc"])
;=> ["b", "aa", "ccc"]

source →

shuffle

(shuffle coll)

Returns a random permutation of coll as a persistent vector.

Arity: 1 · Return: a random permutation of coll as a persistent vector · Evaluation: eager · Effects: nondeterministic · Host: portable stdlib · Throws: not documented as throwing

Related: sort, sort-by, mapv, filterv

No verified inline example: returns nondeterministic order.

source →

mapv

(mapv f ...colls)

Returns a persistent vector of applying f over one or more collections.

Arity: 1+ · Return: a persistent vector of applying f over one or more collections · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: sort-by, shuffle, filterv

(mapv inc [1 2 3])
;=> [2 3 4]

source →

filterv

(filterv pred coll)

Returns a persistent vector of items for which pred is truthy.

Arity: 2 · Return: a persistent vector of items for which pred is truthy · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: shuffle, mapv

(filterv odd? [1 2 3 4])
;=> [1 3]

source →

Transducers

halt-when

(halt-when pred ...args)

Returns a transducer that stops when (pred input) is truthy. With retf, the reduced value is (retf result input).

Arity: 1+ · Return: a transducer that stops when (pred input) is truthy · Evaluation: transducer · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: reduced

No verified inline example: transducer examples need reducing context; behavior is covered by transducer tests.

source →

reduced

(reduced x)

Wraps x as a reduced value to signal early termination to reducing and transducer contexts.

Arity: 1 · Return: Wraps x as a reduced value to signal early termination to reducing and transducer contexts · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: halt-when

(reduce (fn [acc x] (if (> acc 5) (reduced acc) (+ acc x))) 0 [1 2 3 4 5])
;=> 6

source →

Utilities

frequencies

(frequencies coll)

Returns a persistent map of element → occurrence count in coll.

Arity: 1 · Return: a persistent map of element → occurrence count in coll · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: select-keys, merge-with

(frequencies [1 1 2 3 3 3])
;=> {2 1 3 3 1 2}

source →

select-keys

(select-keys m ks)

Returns a new map containing only the entries of m whose keys are in ks.

Arity: 2 · Return: a new map containing only the entries of m whose keys are in ks · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: frequencies, merge-with, replace

(select-keys {:a 1 :b 2 :c 3} [:a :c])
;=> {:c 3 :a 1}

source →

merge-with

(merge-with f ...maps)

Merges maps left-to-right. On key conflict, the value becomes (f existing new).

Arity: 1+ · Return: Merges maps left-to-right · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: frequencies, select-keys, replace, remove

(merge-with + {:a 1} {:a 2 :b 3})
;=> {:a 3 :b 3}

source →

replace

(replace smap ...args)

Replaces items found as keys in smap. With one argument, returns a transducer; with a vector, preserves vector shape.

Arity: 1+ · Return: Replaces items found as keys in smap · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: select-keys, merge-with, remove, complement

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

remove

(remove pred ...args)

Returns items from coll for which (pred item) is falsy. With only pred, returns the remove transducer.

Arity: 1+ · Return: items from coll for which (pred item) is falsy · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: merge-with, replace, complement, distinct?

(remove odd? [1 2 3 4])
;=> (2 4)

source →

complement

(complement f)

Returns a function that calls f and negates the result.

Arity: 1 · Return: a function that calls f and negates the result · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: replace, remove, distinct?, memoize

((complement odd?) 4)
;=> true

source →

distinct?

(distinct? ...vals)

Returns true when no two arguments are structurally equal.

Arity: 0+ · Return: true when no two arguments are structurally equal · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: remove, complement, memoize, not-empty

(distinct? 1 2 3)
;=> true

source →

memoize

(memoize f)

Returns a version of f that caches results keyed by its arguments.

Arity: 1 · Return: a version of f that caches results keyed by its arguments · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: complement, distinct?, not-empty, peek

No verified inline example: the observable behavior is cache reuse across calls, covered by runtime tests.

source →

not-empty

(not-empty coll)

Returns coll if it has at least one item, otherwise nil.

Arity: 1 · Return: coll if it has at least one item, otherwise nil · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: distinct?, memoize, peek, pop

(not-empty [])
;=> nil

source →

peek

(peek coll)

Returns the next item to be popped: the last item for vectors/arrays, first item otherwise.

Arity: 1 · Return: the next item to be popped: the last item for vectors/arrays, first item otherwise · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: memoize, not-empty, pop, bounded-count

(peek [1 2 3])
;=> 3

source →

pop

(pop coll)

Returns coll without the next item to be popped.

Arity: 1 · Return: coll without the next item to be popped · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: not-empty, peek, bounded-count, run!

(pop [1 2 3])
;=> [1 2]

source →

bounded-count

(bounded-count n coll)

Returns min(n, (count coll)), but stops iterating after n elements so it's safe on infinite sequences.

Arity: 2 · Return: min(n, (count coll)), but stops iterating after n elements so it's safe on infinite sequences · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: peek, pop, run!, every-pred

(bounded-count 2 [1 2 3 4])
;=> 2

source →

run!

(run! f coll)

Calls (f item) for side effects on every item in coll. Returns nil.

Arity: 2 · Return: Calls (f item) for side effects on every item in coll · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: pop, bounded-count, every-pred, some-fn

No verified inline example: runs a function for side effects on each item and intentionally returns nil.

source →

every-pred

(every-pred ...preds)

Returns a predicate that is true only when every supplied predicate is truthy for every argument. Strict boolean; short-circuits on the first failure.

Arity: 0+ · Return: a predicate that is true only when every supplied predicate is truthy for every argument · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: bounded-count, run!, some-fn, true?

((every-pred number? pos?) 5)
;=> true

source →

some-fn

(some-fn ...preds)

Returns a predicate that yields the first truthy (pred arg) result (scanning predicates, then arguments), or nil when none match. Short-circuits.

Arity: 0+ · Return: a predicate that yields the first truthy (pred arg) result (scanning predicates, then arguments), or nil when none match · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: run!, every-pred, true?, false?

((some-fn string? number?) "x")
;=> true

source →

true?

(true? x)

Returns true when x is exactly true.

Arity: 1 · Return: true when x is exactly true · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: every-pred, some-fn, false?, identical?

(true? true)
;=> true

source →

false?

(false? x)

Returns true when x is exactly false.

Arity: 1 · Return: true when x is exactly false · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: some-fn, true?, identical?, cat

(false? false)
;=> true

source →

identical?

(identical? a b)

Returns true when a and b are the same JS value/reference.

Arity: 2 · Return: true when a and b are the same JS value/reference · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: true?, false?, cat, dedupe

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

cat

(cat rf)

One-level flattening transducer. Forwards each item of its inputs as separate items downstream.

Arity: 1 · Return: One-level flattening transducer · Evaluation: transducer · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: false?, identical?, dedupe, min

No verified inline example: transducer examples need reducing context; behavior is covered by transducer tests.

source →

dedupe

(dedupe ...args)

Drops consecutive duplicate values from coll. With no args, returns the dedupe transducer.

Arity: 0+ · Return: Drops consecutive duplicate values from coll · Evaluation: transducer · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: identical?, cat, min, max

(dedupe [1 1 2 2 3 1])
;=> (1 2 3 1)

source →

min

(min ...args)

Returns the smallest of the given numbers.

Arity: 0+ · Return: the smallest of the given numbers · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: cat, dedupe, max, min-key

(min 3 1 2)
;=> 1

source →

max

(max ...args)

Returns the largest of the given numbers.

Arity: 0+ · Return: the largest of the given numbers · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: dedupe, min, min-key, max-key

(max 3 1 2)
;=> 3

source →

min-key

(min-key k x ...more)

Returns the argument whose (k arg) value is smallest; keeps the later winner on ties.

Arity: 2+ · Return: the argument whose (k arg) value is smallest; keeps the later winner on ties · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: min, max, max-key, fnil

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

max-key

(max-key k x ...more)

Returns the argument whose (k arg) value is largest; keeps the later winner on ties.

Arity: 2+ · Return: the argument whose (k arg) value is largest; keeps the later winner on ties · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: max, min-key, fnil, trampoline

(max-key count ["a" "ccc" "bb"])
;=> ["a" "ccc" "bb"]

source →

fnil

(fnil f ...defaults)

Wraps f so nil arguments are replaced positionally by defaults. ((fnil + 0) nil) ⇒ 0.

Arity: 1+ · Return: Wraps f so nil arguments are replaced positionally by defaults · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: min-key, max-key, trampoline

((fnil inc 0) nil)
;=> 1

source →

trampoline

(trampoline f ...args)

Iteratively invokes the returned thunk until a non-function appears. The idiom for mutual tail recursion without growing the stack.

Arity: 1+ · Return: Iteratively invokes the returned thunk until a non-function appears · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: max-key, fnil

No verified inline example: needs multi-step callable state; covered by control-flow tests.

source →

Strings

format

(format fmt ...args)

Formats a string with common printf-style conversion specifiers.

Arity: 1+ · Return: Formats a string with common printf-style conversion specifiers · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: printf, str-join

(format "%s=%d" "x" 5)
;=> "x=5"

source →

printf

(printf fmt ...args)

Prints (format fmt ...args) and returns nil.

Arity: 1+ · Return: Prints (format fmt ...args) and returns nil · Evaluation: eager · Effects: output side effect · Host: portable stdlib · Throws: not documented as throwing

Related: format, str-join, split

No verified inline example: writes formatted stdout and would pollute verifier output.

source →

str-join

(str-join separator coll)

Joins items of coll into a single string using separator.

Arity: 2 · Return: Joins items of coll into a single string using separator · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: format, printf, split, str-replace

(str-join ", " [1 2 3])
;=> "1, 2, 3"

source →

split

(split s separator)

Splits string s by separator, returning an array of strings.

Arity: 2 · Return: Splits string s by separator, returning an array of strings · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: printf, str-join, str-replace, trim

(split "a,b,c" ",")
;=> ["a", "b", "c"]

source →

str-replace

(str-replace s match replacement)

Returns a string with every occurrence of match in s replaced by replacement.

Arity: 3 · Return: a string with every occurrence of match in s replaced by replacement · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: str-join, split, trim, upper-case

(str-replace "hello" "l" "L")
;=> "heLLo"

source →

trim

(trim s)

Removes leading and trailing whitespace from s.

Arity: 1 · Return: Removes leading and trailing whitespace from s · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: split, str-replace, upper-case, lower-case

(trim "  hi  ")
;=> "hi"

source →

upper-case

(upper-case s)

Returns s converted to upper case.

Arity: 1 · Return: s converted to upper case · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: str-replace, trim, lower-case, starts-with?

(upper-case "hi")
;=> "HI"

source →

lower-case

(lower-case s)

Returns s converted to lower case.

Arity: 1 · Return: s converted to lower case · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: trim, upper-case, starts-with?, ends-with?

(lower-case "HI")
;=> "hi"

source →

starts-with?

(starts-with? s prefix)

Returns true when string s starts with prefix.

Arity: 2 · Return: true when string s starts with prefix · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: upper-case, lower-case, ends-with?, includes?

(starts-with? "hello" "he")
;=> true

source →

ends-with?

(ends-with? s suffix)

Returns true when string s ends with suffix.

Arity: 2 · Return: true when string s ends with suffix · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: lower-case, starts-with?, includes?, subs

(ends-with? "hello" "lo")
;=> true

source →

includes?

(includes? s substr)

Returns true when string s contains substr.

Arity: 2 · Return: true when string s contains substr · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: starts-with?, ends-with?, subs, re-pattern

(includes? "hello" "ell")
;=> true

source →

subs

(subs s start ...args)

Returns a substring of s from start (inclusive). (subs s start end) slices up to end (exclusive).

Arity: 2+ · Return: a substring of s from start (inclusive) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: ends-with?, includes?, re-pattern, re-matcher

(subs "hello" 1 3)
;=> "el"

source →

re-pattern

(re-pattern pattern)

Returns a RegExp from pattern, or pattern unchanged when already a RegExp.

Arity: 1 · Return: a RegExp from pattern, or pattern unchanged when already a RegExp · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: includes?, subs, re-matcher, re-find

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

re-matcher

(re-matcher pattern s)

Returns a stateful regex matcher for repeated re-find calls.

Arity: 2 · Return: a stateful regex matcher for repeated re-find calls · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: subs, re-pattern, re-find, re-groups

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

re-find

(re-find pattern-or-matcher ...args)

Returns the next regex match. With capture groups, returns a persistent vector of full match and groups.

Arity: 1+ · Return: the next regex match · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: re-pattern, re-matcher, re-groups, re-matches

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

re-groups

(re-groups matcher)

Returns the groups from the most recent successful matcher operation.

Arity: 1 · Return: the groups from the most recent successful matcher operation · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: re-matcher, re-find, re-matches, re-seq

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

re-matches

(re-matches pattern s)

Returns a full-string regex match, or nil when the whole string does not match.

Arity: 2 · Return: a full-string regex match, or nil when the whole string does not match · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: re-find, re-groups, re-seq

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

re-seq

(re-seq pattern s)

Returns a lazy sequence of successive regex matches.

Arity: 2 · Return: a lazy sequence of successive regex matches · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: may throw

Related: re-groups, re-matches

No verified inline example: low-level helper behavior is documented by signature/docstring and covered by focused stdlib tests.

source →

Type Predicates

keyword?

(keyword? x)

Returns true when x is an HQL keyword value.

Arity: 1 · Return: true when x is an HQL keyword value · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: symbol?, list?

(keyword? :a)
;=> true

source →

symbol?

(symbol? x)

Returns true when x is an HQL symbol object.

Arity: 1 · Return: true when x is an HQL symbol object · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: keyword?, list?, vector?

(symbol? (symbol "x"))
;=> true

source →

list?

(list? x)

Returns true when x is a quoted HQL list object.

Arity: 1 · Return: true when x is a quoted HQL list object · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: keyword?, symbol?, vector?, map?

(list? '(1 2))
;=> true

source →

vector?

(vector? x)

Returns true when x is a JS array or HQL persistent vector.

Arity: 1 · Return: true when x is a JS array or HQL persistent vector · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: symbol?, list?, map?, set?

(vector? [1 2])
;=> true

source →

map?

(map? x)

Returns true when x is a plain HQL map or HQL persistent map.

Arity: 1 · Return: true when x is a plain HQL map or HQL persistent map · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: list?, vector?, set?, integer-number?

(map? {:a 1})
;=> true

source →

set?

(set? x)

Returns true when x is a JS Set or HQL persistent set.

Arity: 1 · Return: true when x is a JS Set or HQL persistent set · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: vector?, map?, integer-number?, fractional-number?

(set? #[1 2])
;=> true

source →

integer-number?

(integer-number? x)

Returns true when x is an integer number.

Arity: 1 · Return: true when x is an integer number · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: map?, set?, fractional-number?, completing

(integer-number? 5)
;=> true

source →

fractional-number?

(fractional-number? x)

Returns true when x is a number with a fractional part (the complement of integer-number? over numbers).

Arity: 1 · Return: true when x is a number with a fractional part (the complement of integer-number? over numbers) · Evaluation: eager · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: set?, integer-number?, completing, transduce

(fractional-number? 5.5)
;=> true

source →

completing

(completing f ...args)

Wraps a reducing function/transformer with an optional completion function.

Arity: 1+ · Return: Wraps a reducing function/transformer with an optional completion function · Evaluation: transducer · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: integer-number?, fractional-number?, transduce, sequence

No verified inline example: transducer examples need reducing context; behavior is covered by transducer tests.

source →

transduce

(transduce xform rf ...args)

Applies a transducer to a collection with a reducing function.

Arity: 2+ · Return: Applies a transducer to a collection with a reducing function · Evaluation: transducer · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: fractional-number?, completing, sequence, eduction

No verified inline example: transducer examples need reducing context; behavior is covered by transducer tests.

source →

sequence

(sequence xform-or-coll ...args)

Returns a seq over coll, or over coll transformed by xform.

Arity: 1+ · Return: a seq over coll, or over coll transformed by xform · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: completing, transduce, eduction

(sequence (map inc) [1 2 3])
;=> (2 3 4)

source →

eduction

(eduction xform coll ...colls)

Returns a seqable transducer view over one or more collections.

Arity: 2+ · Return: a seqable transducer view over one or more collections · Evaluation: lazy · Effects: pure/derived value · Host: portable stdlib · Throws: not documented as throwing

Related: transduce, sequence

No verified inline example: transducer examples need reducing context; behavior is covered by transducer tests.

source →

Packages

Userland virtual packages importable as (import [...] from "@hql/<name>").

@hql/ai

5 documented · 5 exported · source →

async ask

(ask prompt ...args)

Sends prompt to the host AI and returns the response. Optional options may include data/schema/model/system/temperature/signal.

Arity: 1+ · Return: Sends prompt to the host AI and returns the response · Evaluation: async · Effects: AI runtime · Host: HLVM AI runtime · Throws: not documented as throwing

No verified inline example: requires HLVM AI runtime setup, so the generated reference keeps it documented without an inline runtime example.

source →

async agent

(agent prompt ...args)

Runs an agentic invocation on the host AI with prompt. Optional options may include data/model/tools/signal.

Arity: 1+ · Return: Runs an agentic invocation on the host AI with prompt · Evaluation: async · Effects: AI runtime · Host: HLVM AI runtime · Throws: not documented as throwing

No verified inline example: requires HLVM AI runtime setup, so the generated reference keeps it documented without an inline runtime example.

source →

chat

(chat messages ...args)

Streams a chat response from the host AI for an array of messages. Returns an AsyncIterable of strings.

Arity: 1+ · Return: Streams a chat response from the host AI for an array of messages · Evaluation: eager · Effects: AI runtime · Host: HLVM AI runtime · Throws: not documented as throwing

No verified inline example: requires HLVM AI runtime setup, so the generated reference keeps it documented without an inline runtime example.

source →

async models

(models)

Returns the list of available models from the host AI adapter.

Arity: 0 · Return: the list of available models from the host AI adapter · Evaluation: async · Effects: AI runtime · Host: HLVM AI runtime · Throws: not documented as throwing

No verified inline example: requires HLVM AI runtime setup, so the generated reference keeps it documented without an inline runtime example.

source →

async status

(status)

Returns the current status object from the host AI adapter.

Arity: 0 · Return: the current status object from the host AI adapter · Evaluation: async · Effects: AI runtime · Host: HLVM AI runtime · Throws: not documented as throwing

No verified inline example: requires HLVM AI runtime setup, so the generated reference keeps it documented without an inline runtime example.

source →

@hql/assert

2 documented · 2 exported · source →

assert

(assert condition message)

Throws Error(message) when condition is falsy. Returns true otherwise.

Arity: 2 · Return: Throws Error(message) when condition is falsy · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: may throw

No verified inline example: the interesting failure path is an intentional thrown error.

source →

assert-equal

(assert-equal actual expected message)

Throws when actual is not deep-equal to expected.

Arity: 3 · Return: Throws when actual is not deep-equal to expected · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

@hql/date

17 documented · 17 exported · source →

now

(now)

Returns the current Unix timestamp in milliseconds.

Arity: 0 · Return: the current Unix timestamp in milliseconds · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

parse

(parse s)

Parses an ISO-8601 (or other Date-compatible) string and returns ms-since-epoch.

Arity: 1 · Return: Parses an ISO-8601 (or other Date-compatible) string and returns ms-since-epoch · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

format

(format ts)

Returns the ISO 8601 string representation of timestamp ts.

Arity: 1 · Return: the ISO 8601 string representation of timestamp ts · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

add

(add ts ms)

Returns ts + ms. Generic millisecond addition.

Arity: 2 · Return: ts + ms · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

diff

(diff a b)

Returns a - b in milliseconds. Negative when a is before b.

Arity: 2 · Return: a - b in milliseconds · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

add-seconds

(add-seconds ts n)

Adds n seconds to timestamp ts. n may be negative.

Arity: 2 · Return: Adds n seconds to timestamp ts · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

add-minutes

(add-minutes ts n)

Adds n minutes to timestamp ts. n may be negative.

Arity: 2 · Return: Adds n minutes to timestamp ts · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

add-hours

(add-hours ts n)

Adds n hours to timestamp ts. n may be negative.

Arity: 2 · Return: Adds n hours to timestamp ts · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

add-days

(add-days ts n)

Adds n days to timestamp ts. Drifts by up to 1 hour across DST.

Arity: 2 · Return: Adds n days to timestamp ts · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

diff-seconds

(diff-seconds a b)

Returns a - b in whole seconds (truncated toward zero).

Arity: 2 · Return: a - b in whole seconds (truncated toward zero) · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

diff-minutes

(diff-minutes a b)

Returns a - b in whole minutes (truncated toward zero).

Arity: 2 · Return: a - b in whole minutes (truncated toward zero) · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

diff-hours

(diff-hours a b)

Returns a - b in whole hours (truncated toward zero).

Arity: 2 · Return: a - b in whole hours (truncated toward zero) · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

diff-days

(diff-days a b)

Returns a - b in whole days (truncated toward zero).

Arity: 2 · Return: a - b in whole days (truncated toward zero) · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

before?

(before? a b)

Returns true when timestamp a is strictly before b.

Arity: 2 · Return: true when timestamp a is strictly before b · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

after?

(after? a b)

Returns true when timestamp a is strictly after b.

Arity: 2 · Return: true when timestamp a is strictly after b · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

start-of-day

(start-of-day ts)

Returns the timestamp at the start of ts's local calendar day (00:00:00.000).

Arity: 1 · Return: the timestamp at the start of ts's local calendar day (00:00:00.000) · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

end-of-day

(end-of-day ts)

Returns the timestamp at the end of ts's local calendar day (23:59:59.999).

Arity: 1 · Return: the timestamp at the end of ts's local calendar day (23:59:59.999) · Evaluation: eager · Effects: pure/derived value · Host: host clock/timezone · Throws: not documented as throwing

No verified inline example: requires host clock/timezone setup, so the generated reference keeps it documented without an inline runtime example.

source →

@hql/encoding

7 documented · 7 exported · source →

base64-encode

(base64-encode s)

Encodes ASCII string s to base64. Throws on non-ASCII; use a Uint8Array path for binary.

Arity: 1 · Return: Encodes ASCII string s to base64 · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

base64-decode

(base64-decode s)

Decodes base64 string s to its original string. Throws on malformed input.

Arity: 1 · Return: Decodes base64 string s to its original string · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

hex-encode

(hex-encode bytes)

Encodes a Uint8Array or byte array bytes to a lowercase hex string.

Arity: 1 · Return: Encodes a Uint8Array or byte array bytes to a lowercase hex string · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

hex-decode

(hex-decode hex)

Decodes a hex string hex to a Uint8Array. Throws on odd length or non-hex chars.

Arity: 1 · Return: Decodes a hex string hex to a Uint8Array · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

uri-encode

(uri-encode s)

URI-encodes s (every byte except RFC3986 unreserved chars becomes %XX).

Arity: 1 · Return: URI-encodes s (every byte except RFC3986 unreserved chars becomes %XX) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

uri-decode

(uri-decode s)

Decodes a URI-encoded string s. Throws on malformed % sequences.

Arity: 1 · Return: Decodes a URI-encoded string s · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

uuid

(uuid)

Returns a random v4 UUID string. Requires a host with crypto.randomUUID.

Arity: 0 · Return: a random v4 UUID string · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

@hql/env

5 documented · 5 exported · source →

getenv

(getenv name)

Returns the value of the environment variable name, or nil if unset.

Arity: 1 · Return: the value of the environment variable name, or nil if unset · Evaluation: eager · Effects: environment · Host: process environment · Throws: not documented as throwing

No verified inline example: requires process environment setup, so the generated reference keeps it documented without an inline runtime example.

source →

has?

(has? name)

Returns true when the environment variable name is set (not undefined).

Arity: 1 · Return: true when the environment variable name is set (not undefined) · Evaluation: eager · Effects: environment · Host: process environment · Throws: not documented as throwing

No verified inline example: requires process environment setup, so the generated reference keeps it documented without an inline runtime example.

source →

setenv

(setenv name value)

Sets the environment variable name to value in the current process.

Arity: 2 · Return: Sets the environment variable name to value in the current process · Evaluation: eager · Effects: environment · Host: process environment · Throws: not documented as throwing

No verified inline example: requires process environment setup, so the generated reference keeps it documented without an inline runtime example.

source →

cwd

(cwd)

Returns the current working directory.

Arity: 0 · Return: the current working directory · Evaluation: eager · Effects: environment · Host: process environment · Throws: not documented as throwing

No verified inline example: requires process environment setup, so the generated reference keeps it documented without an inline runtime example.

source →

home-dir

(home-dir)

Returns the user's home directory (HOME on Unix, USERPROFILE on Windows), or nil.

Arity: 0 · Return: the user's home directory (HOME on Unix, USERPROFILE on Windows), or nil · Evaluation: eager · Effects: environment · Host: process environment · Throws: not documented as throwing

No verified inline example: requires process environment setup, so the generated reference keeps it documented without an inline runtime example.

source →

@hql/fs

15 documented · 15 exported · source →

read

(read path)

Reads the contents of path as a UTF-8 string. Returns a Promise.

Arity: 1 · Return: Reads the contents of path as a UTF-8 string · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

write

(write path content)

Writes content (a string) to path, overwriting any existing file. Returns a Promise.

Arity: 2 · Return: Writes content (a string) to path, overwriting any existing file · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

remove

(remove path)

Removes the file at path. Returns a Promise.

Arity: 1 · Return: Removes the file at path · Evaluation: lazy · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

exists?

(exists? path)

Returns true when a file or directory exists at path (synchronous).

Arity: 1 · Return: true when a file or directory exists at path (synchronous) · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

read-bytes

(read-bytes path)

Reads the contents of path as a Uint8Array. Returns a Promise.

Arity: 1 · Return: Reads the contents of path as a Uint8Array · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

stat

(stat path)

Returns {isFile, isDirectory, size} for the file at path, or nil if missing. Uses statSync — synchronous and nil-safe (no exception on missing path).

Arity: 1 · Return: {isFile, isDirectory, size} for the file at path, or nil if missing · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

async read-json

(read-json path)

Reads path as UTF-8 and JSON-parses the contents. Rejects on malformed JSON.

Arity: 1 · Return: Reads path as UTF-8 and JSON-parses the contents · Evaluation: async · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

async write-json

(write-json path obj)

JSON-stringifies obj and writes it to path. Returns a Promise.

Arity: 2 · Return: JSON-stringifies obj and writes it to path · Evaluation: async · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

async read-lines

(read-lines path)

Reads path as UTF-8 text and splits into lines on \r\n, \n, or \r.

Arity: 1 · Return: Reads path as UTF-8 text and splits into lines on \r\n, \n, or \r · Evaluation: async · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

list-dir

(list-dir path)

Returns a Promise of an array of {name, isFile, isDirectory} entries for path.

Arity: 1 · Return: a Promise of an array of {name, isFile, isDirectory} entries for path · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

mkdir

(mkdir path)

Creates the directory at path. Throws when the parent does not exist; use mkdir-recursive to create intermediate directories.

Arity: 1 · Return: creates the directory at path · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

mkdir-recursive

(mkdir-recursive path)

Creates path and any missing intermediate directories.

Arity: 1 · Return: creates path and any missing intermediate directories · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

copy

(copy src dst)

Copies the file at src to dst. Overwrites dst if it exists.

Arity: 2 · Return: Copies the file at src to dst · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

move

(move src dst)

Moves/renames the file at src to dst.

Arity: 2 · Return: Moves/renames the file at src to dst · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

remove-recursive

(remove-recursive path)

Removes path and (if it is a directory) all its contents.

Arity: 1 · Return: Removes path and (if it is a directory) all its contents · Evaluation: eager · Effects: filesystem · Host: filesystem · Throws: not documented as throwing

No verified inline example: requires filesystem setup, so the generated reference keeps it documented without an inline runtime example.

source →

@hql/http

7 documented · 7 exported · source →

request

(request url options)

Performs an HTTP request to url with optional options (method, headers, body). Returns a Promise<Response>.

Arity: 2 · Return: Performs an HTTP request to url with optional options (method, headers, body) · Evaluation: eager · Effects: network · Host: network · Throws: not documented as throwing

No verified inline example: requires network setup, so the generated reference keeps it documented without an inline runtime example.

source →

get

(get url)

Performs a GET request against url and returns a Promise<Response>.

Arity: 1 · Return: Performs a GET request against url and returns a Promise<Response> · Evaluation: eager · Effects: network · Host: network · Throws: not documented as throwing

No verified inline example: requires network setup, so the generated reference keeps it documented without an inline runtime example.

source →

post

(post url body)

Performs a POST request to url with the given body. Returns a Promise<Response>.

Arity: 2 · Return: Performs a POST request to url with the given body · Evaluation: eager · Effects: network · Host: network · Throws: not documented as throwing

No verified inline example: requires network setup, so the generated reference keeps it documented without an inline runtime example.

source →

async get-json

(get-json url)

Performs a GET request and parses the response body as JSON.

Arity: 1 · Return: Performs a GET request and parses the response body as JSON · Evaluation: async · Effects: network · Host: network · Throws: not documented as throwing

No verified inline example: requires network setup, so the generated reference keeps it documented without an inline runtime example.

source →

async post-json

(post-json url body)

Performs a POST with a JSON-encoded body and parses the response as JSON. Sets Content-Type: application/json automatically.

Arity: 2 · Return: Performs a POST with a JSON-encoded body and parses the response as JSON · Evaluation: async · Effects: network · Host: network · Throws: not documented as throwing

No verified inline example: requires network setup, so the generated reference keeps it documented without an inline runtime example.

source →

status-ok?

(status-ok? res)

Returns true when the response status is in the 2xx range.

Arity: 1 · Return: true when the response status is in the 2xx range · Evaluation: eager · Effects: network · Host: network · Throws: not documented as throwing

No verified inline example: requires network setup, so the generated reference keeps it documented without an inline runtime example.

source →

status-code

(status-code res)

Returns the numeric status code of the response.

Arity: 1 · Return: the numeric status code of the response · Evaluation: eager · Effects: network · Host: network · Throws: not documented as throwing

No verified inline example: requires network setup, so the generated reference keeps it documented without an inline runtime example.

source →

@hql/json

4 documented · 4 exported · source →

parse

(parse s)

Parses a JSON string into an HQL value. Throws SyntaxError on malformed input.

Arity: 1 · Return: Parses a JSON string into an HQL value · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

stringify

(stringify obj)

Serializes an HQL value to a JSON string.

Arity: 1 · Return: Serializes an HQL value to a JSON string · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

parse-safe

(parse-safe s default)

Parses a JSON string; returns default if s is invalid JSON.

Arity: 2 · Return: Parses a JSON string; returns default if s is invalid JSON · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

pretty-stringify

(pretty-stringify obj indent)

Serializes with indent spaces of indentation (pass 2 for the common case).

Arity: 2 · Return: Serializes with indent spaces of indentation (pass 2 for the common case) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

@hql/math

26 documented · 26 exported · source →

sqrt

(sqrt x)

Returns the square root of x. Negative input returns NaN.

Arity: 1 · Return: the square root of x · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

pow

(pow base exp)

Returns base raised to the power exp.

Arity: 2 · Return: base raised to the power exp · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

log

(log x)

Natural logarithm (base e) of x. Negative input returns NaN.

Arity: 1 · Return: Natural logarithm (base e) of x · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

log2

(log2 x)

Logarithm base 2 of x.

Arity: 1 · Return: Logarithm base 2 of x · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

log10

(log10 x)

Logarithm base 10 of x.

Arity: 1 · Return: Logarithm base 10 of x · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

exp

(exp x)

Returns e^x.

Arity: 1 · Return: e^x · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

sin

(sin x)

Sine of x in radians.

Arity: 1 · Return: Sine of x in radians · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

cos

(cos x)

Cosine of x in radians.

Arity: 1 · Return: Cosine of x in radians · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

tan

(tan x)

Tangent of x in radians.

Arity: 1 · Return: Tangent of x in radians · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

asin

(asin x)

Arcsine of x in radians.

Arity: 1 · Return: Arcsine of x in radians · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

acos

(acos x)

Arccosine of x in radians.

Arity: 1 · Return: Arccosine of x in radians · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

atan

(atan x)

Arctangent of x in radians.

Arity: 1 · Return: Arctangent of x in radians · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

atan2

(atan2 y x)

Arctangent of y/x in radians, handling all quadrants.

Arity: 2 · Return: Arctangent of y/x in radians, handling all quadrants · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

floor

(floor x)

Largest integer ≤ x.

Arity: 1 · Return: Largest integer ≤ x · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

ceil

(ceil x)

Smallest integer ≥ x.

Arity: 1 · Return: Smallest integer ≥ x · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

round

(round x)

x rounded to nearest integer.

Arity: 1 · Return: x rounded to nearest integer · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

truncate

(truncate x)

x with the fractional part removed (toward zero).

Arity: 1 · Return: x with the fractional part removed (toward zero) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

random

(random)

Returns a pseudo-random number in [0, 1).

Arity: 0 · Return: a pseudo-random number in [0, 1) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

random-int

(random-int min max)

Returns a pseudo-random integer in [min, max) (max exclusive).

Arity: 2 · Return: a pseudo-random integer in [min, max) (max exclusive) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

parse-int

(parse-int s)

Parses s as a base-10 integer. Returns NaN on failure.

Arity: 1 · Return: Parses s as a base-10 integer · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

parse-float

(parse-float s)

Parses s as a float. Returns NaN on failure.

Arity: 1 · Return: Parses s as a float · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

nan?

(nan? x)

Returns true when x is NaN.

Arity: 1 · Return: true when x is NaN · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

infinity?

(infinity? x)

Returns true when x is +Infinity or -Infinity.

Arity: 1 · Return: true when x is +Infinity or -Infinity · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

finite?

(finite? x)

Returns true when x is a finite number (not NaN, not Infinity).

Arity: 1 · Return: true when x is a finite number (not NaN, not Infinity) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

pi

(pi)

Constant binding pi exported by this module.

Arity: 0 · Return: Constant binding pi exported by this module · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

e

(e)

Constant binding e exported by this module.

Arity: 0 · Return: Constant binding e exported by this module · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

@hql/media

7 documented · 7 exported · source →

media-type

(media-type)

Constant binding media-type exported by this module.

Arity: 0 · Return: Constant binding media-type exported by this module · Evaluation: eager · Effects: media host · Host: filesystem/network media host · Throws: not documented as throwing

No verified inline example: requires filesystem/network media host setup, so the generated reference keeps it documented without an inline runtime example.

source →

create-media

(create-media type mime-type base64-data source)

Constructs a Media object with type, mimeType, base64 data, and optional source path/URL.

Arity: 4 · Return: Constructs a Media object with type, mimeType, base64 data, and optional source path/URL · Evaluation: eager · Effects: media host · Host: filesystem/network media host · Throws: not documented as throwing

No verified inline example: requires filesystem/network media host setup, so the generated reference keeps it documented without an inline runtime example.

source →

media?

(media? value)

Returns true when value is a Media object (tagged with hql_media).

Arity: 1 · Return: true when value is a Media object (tagged with hql_media) · Evaluation: eager · Effects: media host · Host: filesystem/network media host · Throws: not documented as throwing

No verified inline example: requires filesystem/network media host setup, so the generated reference keeps it documented without an inline runtime example.

source →

async read-image

(read-image path)

Read an image file and return a Media object for vision models

Arity: 1 · Return: Read an image file and return a Media object for vision models · Evaluation: async · Effects: media host · Host: filesystem/network media host · Throws: not documented as throwing

No verified inline example: requires filesystem/network media host setup, so the generated reference keeps it documented without an inline runtime example.

source →

async read-media

(read-media path)

Read any media file and return a Media object

Arity: 1 · Return: Read any media file and return a Media object · Evaluation: async · Effects: media host · Host: filesystem/network media host · Throws: not documented as throwing

No verified inline example: requires filesystem/network media host setup, so the generated reference keeps it documented without an inline runtime example.

source →

media-from-base64

(media-from-base64 mime-type base64-data)

Create a Media object from raw base64 data

Arity: 2 · Return: creates a Media object from raw base64 data · Evaluation: eager · Effects: media host · Host: filesystem/network media host · Throws: not documented as throwing

No verified inline example: requires filesystem/network media host setup, so the generated reference keeps it documented without an inline runtime example.

source →

async read-media-url

(read-media-url url)

Fetch media from a URL and return a Media object

Arity: 1 · Return: Fetch media from a URL and return a Media object · Evaluation: async · Effects: media host · Host: filesystem/network media host · Throws: not documented as throwing

No verified inline example: requires filesystem/network media host setup, so the generated reference keeps it documented without an inline runtime example.

source →

@hql/path

8 documented · 8 exported · source →

sep

(sep)

Constant binding sep exported by this module.

Arity: 0 · Return: Constant binding sep exported by this module · Evaluation: eager · Effects: pure/derived value · Host: portable path rules · Throws: not documented as throwing

No verified inline example: requires portable path rules setup, so the generated reference keeps it documented without an inline runtime example.

source →

join

(join ...parts)

Joins path segments with /, collapsing duplicate separators.

Arity: 0+ · Return: Joins path segments with /, collapsing duplicate separators · Evaluation: eager · Effects: pure/derived value · Host: portable path rules · Throws: not documented as throwing

No verified inline example: requires portable path rules setup, so the generated reference keeps it documented without an inline runtime example.

source →

basename

(basename path)

Returns the last segment of path (file name with extension).

Arity: 1 · Return: the last segment of path (file name with extension) · Evaluation: eager · Effects: pure/derived value · Host: portable path rules · Throws: not documented as throwing

No verified inline example: requires portable path rules setup, so the generated reference keeps it documented without an inline runtime example.

source →

dirname

(dirname path)

Returns everything before the last / of path, or "." if none.

Arity: 1 · Return: everything before the last / of path, or "." if none · Evaluation: eager · Effects: pure/derived value · Host: portable path rules · Throws: not documented as throwing

No verified inline example: requires portable path rules setup, so the generated reference keeps it documented without an inline runtime example.

source →

extname

(extname path)

Returns the file extension including the leading dot (e.g. ".txt"), or "".

Arity: 1 · Return: the file extension including the leading dot (e.g · Evaluation: eager · Effects: pure/derived value · Host: portable path rules · Throws: not documented as throwing

No verified inline example: requires portable path rules setup, so the generated reference keeps it documented without an inline runtime example.

source →

absolute?

(absolute? path)

Returns true when path starts with /.

Arity: 1 · Return: true when path starts with / · Evaluation: eager · Effects: pure/derived value · Host: portable path rules · Throws: not documented as throwing

No verified inline example: requires portable path rules setup, so the generated reference keeps it documented without an inline runtime example.

source →

normalize

(normalize path)

Collapses ./ segments and resolves ../ segments where possible.

Arity: 1 · Return: Collapses ./ segments and resolves ../ segments where possible · Evaluation: eager · Effects: pure/derived value · Host: portable path rules · Throws: not documented as throwing

No verified inline example: requires portable path rules setup, so the generated reference keeps it documented without an inline runtime example.

source →

relative

(relative from to)

Returns the relative path from from to to, both normalized.

Arity: 2 · Return: the relative path from from to to, both normalized · Evaluation: eager · Effects: pure/derived value · Host: portable path rules · Throws: not documented as throwing

No verified inline example: requires portable path rules setup, so the generated reference keeps it documented without an inline runtime example.

source →

@hql/pprint

3 documented · 3 exported · source →

pp-str

(pp-str obj indent)

Returns a pretty-printed string of obj. Defaults to 2-space indentation; pass nil for compact.

Arity: 2 · Return: a pretty-printed string of obj · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

pp

(pp obj indent)

Prints (pp-str obj indent) followed by a newline. Returns nil.

Arity: 2 · Return: Prints (pp-str obj indent) followed by a newline · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

pretty?

(pretty? obj max-width)

Returns true when no line in (pp-str obj 2) exceeds max-width characters.

Arity: 2 · Return: true when no line in (pp-str obj 2) exceeds max-width characters · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

@hql/regex

8 documented · 8 exported · source →

pattern

(pattern src flags)

Compiles a regex from src with optional flags (e.g. "gi"). Pass nil for no flags.

Arity: 2 · Return: Compiles a regex from src with optional flags (e.g · Evaluation: eager · Effects: pure/derived value · Host: portable RegExp · Throws: not documented as throwing

No verified inline example: requires portable RegExp setup, so the generated reference keeps it documented without an inline runtime example.

source →

find

(find s re)

Returns the first match of re in s, or nil if none.

Arity: 2 · Return: the first match of re in s, or nil if none · Evaluation: eager · Effects: pure/derived value · Host: portable RegExp · Throws: not documented as throwing

No verified inline example: requires portable RegExp setup, so the generated reference keeps it documented without an inline runtime example.

source →

find-all

(find-all s re)

Returns an array of all matched strings. re must have the 'g' flag.

Arity: 2 · Return: an array of all matched strings · Evaluation: eager · Effects: pure/derived value · Host: portable RegExp · Throws: not documented as throwing

No verified inline example: requires portable RegExp setup, so the generated reference keeps it documented without an inline runtime example.

source →

match?

(match? s re)

Returns true when s matches re anywhere.

Arity: 2 · Return: true when s matches re anywhere · Evaluation: eager · Effects: pure/derived value · Host: portable RegExp · Throws: not documented as throwing

No verified inline example: requires portable RegExp setup, so the generated reference keeps it documented without an inline runtime example.

source →

replace

(replace s re replacement)

Replaces the first match of re in s with replacement.

Arity: 3 · Return: Replaces the first match of re in s with replacement · Evaluation: eager · Effects: pure/derived value · Host: portable RegExp · Throws: not documented as throwing

No verified inline example: requires portable RegExp setup, so the generated reference keeps it documented without an inline runtime example.

source →

replace-all

(replace-all s re replacement)

Replaces every match of re in s with replacement. re must have the 'g' flag.

Arity: 3 · Return: Replaces every match of re in s with replacement · Evaluation: eager · Effects: pure/derived value · Host: portable RegExp · Throws: not documented as throwing

No verified inline example: requires portable RegExp setup, so the generated reference keeps it documented without an inline runtime example.

source →

split

(split s re)

Splits s at every match of re.

Arity: 2 · Return: Splits s at every match of re · Evaluation: eager · Effects: pure/derived value · Host: portable RegExp · Throws: not documented as throwing

No verified inline example: requires portable RegExp setup, so the generated reference keeps it documented without an inline runtime example.

source →

escape

(escape s)

Escapes s so it can be embedded literally inside a pattern.

Arity: 1 · Return: Escapes s so it can be embedded literally inside a pattern · Evaluation: eager · Effects: pure/derived value · Host: portable RegExp · Throws: not documented as throwing

No verified inline example: requires portable RegExp setup, so the generated reference keeps it documented without an inline runtime example.

source →

@hql/set

8 documented · 8 exported · source →

to-array

(to-array s)

Returns the elements of s as a JS array (order: insertion order).

Arity: 1 · Return: the elements of s as a JS array (order: insertion order) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

union

(union ...sets)

Returns a new Set containing every element from all input sets.

Arity: 0+ · Return: a new Set containing every element from all input sets · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

intersection

(intersection ...sets)

Returns a new Set containing only elements present in every input set.

Arity: 0+ · Return: a new Set containing only elements present in every input set · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

difference

(difference ...sets)

Returns a new Set containing elements in the first set but not in any of the others.

Arity: 0+ · Return: a new Set containing elements in the first set but not in any of the others · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

subset?

(subset? sub larger)

Returns true when every element of sub is in larger.

Arity: 2 · Return: true when every element of sub is in larger · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

superset?

(superset? larger sub)

Returns true when larger contains every element of sub.

Arity: 2 · Return: true when larger contains every element of sub · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

disjoint?

(disjoint? a b)

Returns true when a and b share no elements.

Arity: 2 · Return: true when a and b share no elements · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

select

(select pred s)

Returns a new Set of s elements for which pred returns truthy.

Arity: 2 · Return: a new Set of s elements for which pred returns truthy · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

@hql/string

23 documented · 23 exported · source →

split

(split s sep)

Splits string s at every occurrence of sep. Returns an array of substrings.

Arity: 2 · Return: Splits string s at every occurrence of sep · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

join

(join arr sep)

Joins array arr of strings into one string with sep between elements.

Arity: 2 · Return: Joins array arr of strings into one string with sep between elements · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

trim

(trim s)

Returns s with leading and trailing whitespace removed.

Arity: 1 · Return: s with leading and trailing whitespace removed · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

upper-case

(upper-case s)

Returns s with all characters upper-cased.

Arity: 1 · Return: s with all characters upper-cased · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

lower-case

(lower-case s)

Returns s with all characters lower-cased.

Arity: 1 · Return: s with all characters lower-cased · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

starts-with?

(starts-with? s search)

Returns true when s begins with search.

Arity: 2 · Return: true when s begins with search · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

ends-with?

(ends-with? s search)

Returns true when s ends with search.

Arity: 2 · Return: true when s ends with search · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

replace

(replace s search replacement)

Replaces the first occurrence of search in s with replacement.

Arity: 3 · Return: Replaces the first occurrence of search in s with replacement · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

blank?

(blank? s)

Returns true when s is nil, empty, or contains only whitespace.

Arity: 1 · Return: true when s is nil, empty, or contains only whitespace · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

not-blank?

(not-blank? s)

Opposite of blank? — returns true when s has at least one non-whitespace character.

Arity: 1 · Return: Opposite of blank? — returns true when s has at least one non-whitespace character · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

capitalize

(capitalize s)

Returns s with the first character upper-cased and the rest lower-cased.

Arity: 1 · Return: s with the first character upper-cased and the rest lower-cased · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

pad-left

(pad-left s width pad)

Pads s on the left with pad (default " ") until it reaches width.

Arity: 3 · Return: Pads s on the left with pad (default " ") until it reaches width · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

pad-right

(pad-right s width pad)

Pads s on the right with pad (default " ") until it reaches width.

Arity: 3 · Return: Pads s on the right with pad (default " ") until it reaches width · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

repeat-str

(repeat-str s n)

Returns s concatenated n times. Throws if n is negative.

Arity: 2 · Return: s concatenated n times · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

reverse-str

(reverse-str s)

Returns s with character order reversed (ASCII; combining marks may render oddly).

Arity: 1 · Return: s with character order reversed (ASCII; combining marks may render oddly) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

index-of

(index-of s search)

Returns the first index of search in s, or -1 if not found.

Arity: 2 · Return: the first index of search in s, or -1 if not found · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

last-index-of

(last-index-of s search)

Returns the last index of search in s, or -1 if not found.

Arity: 2 · Return: the last index of search in s, or -1 if not found · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

replace-first

(replace-first s search replacement)

Replaces only the first match of search (string or RegExp) in s with replacement.

Arity: 3 · Return: Replaces only the first match of search (string or RegExp) in s with replacement · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

split-lines

(split-lines s)

Splits s into lines on \r\n, \r, or \n.

Arity: 1 · Return: Splits s into lines on \r\n, \r, or \n · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

camel-case

(camel-case s)

Converts s (space-, dash-, or underscore-separated) to camelCase.

Arity: 1 · Return: Converts s (space-, dash-, or underscore-separated) to camelCase · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

kebab-case

(kebab-case s)

Converts s to kebab-case (lowercased, dash-separated).

Arity: 1 · Return: Converts s to kebab-case (lowercased, dash-separated) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

snake-case

(snake-case s)

Converts s to snake_case (lowercased, underscore-separated).

Arity: 1 · Return: Converts s to snake_case (lowercased, underscore-separated) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →

title-case

(title-case s)

Converts s to Title Case (each word capitalized, spaces preserved).

Arity: 1 · Return: Converts s to Title Case (each word capitalized, spaces preserved) · Evaluation: eager · Effects: pure/derived value · Host: portable · Throws: not documented as throwing

No verified inline example: package examples require scoped import fixtures; package behavior is covered by package and compiler tests.

source →