tur/macros
cond
(cond [& clauses])
variadic conditional branching via nested if chains.
| & clauses -- alternating test/expression pairs, with optional :else at end |
Since: Phase 7
when
(when [test body])
evaluate body only if test is truthy.
| test | the condition to evaluate | |
| body | expression to evaluate when test is truthy |
Since: Phase 7
unless
(unless [test body])
evaluate body only if test is falsy.
| test | the condition to evaluate | |
| body | expression to evaluate when test is falsy |
Since: Phase 7
must!
(must! [expr])
unwrap an option or result value, panicking if absent.
| expr | an option or result expression to unwrap |
Since: Phase R4
must-msg!
(must-msg! [expr msg])
unwrap an option or result value with a custom panic message.
| expr | an option or result expression to unwrap | |
| msg | the message to panic with if the value is absent |
Since: Phase R4
ignore!
(ignore! [expr])
explicitly discard a result value.
| expr | the expression whose value should be discarded |
Since: Phase R6
do-m
(do-m [& forms])
monadic do-notation using .bind dispatch.
| & forms -- alternating variable/monadic-action pairs followed by a body; | ||
| the last form is the body expression |
Since: Phase HKT H6
for
(for [binding-vec & body])
monadic comprehension with optional guards.
| binding-vec | flat vector of alternating var/collection pairs, | |
| with optional :when guard clauses interspersed | ||
| & body -- the body expression(s) to lift into the monad |
Since: Phase HKT H7
assert!
(assert! [condition])
Phase C1: Runtime contract macros
| condition | the boolean expression to check |
Since: Phase C1
assert-msg!
(assert-msg! [condition msg])
unconditional sanity check with custom panic message.
| condition | the boolean expression to check | |
| msg | the message string to use when panicking |
Since: Phase C1
require!
(require! [condition])
precondition check at function entry, panics with "Precondition failed" if false.
| condition | the boolean precondition to enforce |
Since: Phase C1
require-msg!
(require-msg! [condition msg])
precondition check with custom panic message.
| condition | the boolean precondition to enforce | |
| msg | the message string to use when panicking |
Since: Phase C1
ensure!
(ensure! [condition])
postcondition check, panics with "Postcondition failed" if false.
| condition | the boolean postcondition to enforce |
Since: Phase C1
ensure-msg!
(ensure-msg! [condition msg])
postcondition check with custom panic message.
| condition | the boolean postcondition to enforce | |
| msg | the message string to use when panicking |
Since: Phase C1
invariant!
(invariant! [obj predicate])
check a structural invariant on a value, panics with "Invariant failed" if false.
| obj | the value to check | |
| predicate | a single-argument function that returns true if the invariant holds |
Since: Phase C1
invariant-msg!
(invariant-msg! [obj predicate msg])
check a structural invariant with custom panic message.
| obj | the value to check | |
| predicate | a single-argument function that returns true if the invariant holds | |
| msg | the message string to use when panicking |
Since: Phase C1
curry
(curry [f])
convert a 2-argument function to its curried form.
| f | a 2-argument function |
Since: CY3
doc
(doc [name])
print documentation for a function, macro, or struct at the REPL.
| name | symbol whose documentation to display |
Since: Phase D1 (auto-docs)