Reusable Zig body templates for common patterns. Each template returns
a string of Zig source a defnz body can splice in or call. The
templates are data-driven: they take the parameter names and produce
idiomatic Zig, so the user does not hand-write the same boilerplate
for every binary operation, slice fold, or comparison.
(defnz square [x :f64 :ret :f64]
(template/binary-op "*" 'x 'x))
(defnz sum-slice [xs [:slice :const :f64] :ret :f64]
(template/slice-fold 'xs 0.0 "+"))
Reusable Zig body templates for common patterns. Each template returns
a string of Zig source a `defnz` body can splice in or call. The
templates are data-driven: they take the parameter names and produce
idiomatic Zig, so the user does not hand-write the same boilerplate
for every binary operation, slice fold, or comparison.
(defnz square [x :f64 :ret :f64]
(template/binary-op "*" 'x 'x))
(defnz sum-slice [xs [:slice :const :f64] :ret :f64]
(template/slice-fold 'xs 0.0 "+"))(binary-op op lhs rhs)Zig source for lhs op rhs, returning the result. A simple wrapper
for the most common body shape: one binary operation on two named
bindings.
Zig source for `lhs op rhs`, returning the result. A simple wrapper for the most common body shape: one binary operation on two named bindings.
(clamp val lo hi)Zig source that clamps val between lo and hi.
Zig source that clamps `val` between `lo` and `hi`.
(comparator op lhs rhs)Zig source for a comparison returning bool. op is one of <, >,
<=, >=, ==, !=.
Zig source for a comparison returning bool. `op` is one of `<`, `>`, `<=`, `>=`, `==`, `!=`.
(conditional pred t f)Zig source for a conditional return: if (pred) return t; return f;
Zig source for a conditional return: `if (pred) return t; return f;`
(reducer-step binding init op)(reducer-step binding acc-type init op)Zig source that applies op (a compound assignment like +=, *=)
between acc and each element of binding, with an optional
accumulator type annotation.
Zig source that applies `op` (a compound assignment like `+=`, `*=`) between `acc` and each element of `binding`, with an optional accumulator type annotation.
(slice-fold binding init op)Zig source that folds a slice with an accumulator. Iterates binding,
combines each element with the accumulator using the compound assignment
op (e.g. +=, *=, etc.), starting from init. Returns the accumulator.
Zig source that folds a slice with an accumulator. Iterates `binding`, combines each element with the accumulator using the compound assignment `op` (e.g. `+=`, `*=`, etc.), starting from `init`. Returns the accumulator.
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 |