Public API for the utils component.
Provides generic utilities including:
Public API for the utils component. Provides generic utilities including: - Assertion macros (have, have?) - Control flow macros (cond*) - Math utilities (sqr, sqrd, cubed, trunc) - Collection utilities (update-vals, filter-map, deep-merge) - Tree walking (walk, postwalk) - Debugging (spy, report)
(assertion-error msg data)Create an AssertionError with message and data, with stack trace adjusted to appear at assertion site.
Create an AssertionError with message and data, with stack trace adjusted to appear at assertion site.
(assoc-tag sym t)Associate a type tag to a symbol's metadata.
Associate a type tag to a symbol's metadata.
(cond* & clauses)A cond variant that allows :let bindings visible to subsequent clauses.
A cond variant that allows :let bindings visible to subsequent clauses.
(filter-map pred m)Filter map entries based on a predicate applied to values. Return a new map containing only entries where (pred value) returns true.
Filter map entries based on a predicate applied to values. Return a new map containing only entries where (pred value) returns true.
(have x)(have f x)(have f x data)Assertion macro inspired by truss. Returns argument if predicate succeeds, throws AssertionError otherwise.
Assertion macro inspired by truss. Returns argument if predicate succeeds, throws AssertionError otherwise.
(have? x & args)Assertion macro inspired by truss. Returns true if predicate succeeds, throws AssertionError otherwise.
Assertion macro inspired by truss. Returns true if predicate succeeds, throws AssertionError otherwise.
(postwalk f form)Performs a depth-first, post-order traversal of form. Calls f on each sub-form, uses f's return value in place of the original.
Performs a depth-first, post-order traversal of form. Calls f on each sub-form, uses f's return value in place of the original.
(provide-update-vals)Polyfill macro for update-vals
Polyfill macro for update-vals
(reduce-double-vector f init v)Reduce a double primitive value over a vector.
Reduce a double primitive value over a vector.
(report format-string & values)Print format output.
Print format output.
(spy msg x)Debug helper: print message and value, return value.
Debug helper: print message and value, return value.
(sqr x)Square of argument (macro for inlining)
Square of argument (macro for inlining)
(trunc x)Round towards zero to an integral value.
Round towards zero to an integral value.
(truthy? x)Return true if x is neither nil nor false.
Return true if x is neither nil nor false.
(update-vals m f)m f => {k (f v) ...}
Given a map m and a function f of 1-argument, returns a new map where the keys of m are mapped to result of applying f to the corresponding values of m.
m f => {k (f v) ...}
Given a map m and a function f of 1-argument, returns a new map where
the keys of m are mapped to result of applying f to the corresponding
values of m.(walk inner outer form)Traverses form, an arbitrary data structure (preserves metadata). Applies inner to each element, building up a data structure of the same type, then applies outer to the result.
Traverses form, an arbitrary data structure (preserves metadata). Applies inner to each element, building up a data structure of the same type, then applies outer to the result.
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |