Type predicates, numeric predicates, and logic operations for PTC-Lisp runtime.
Provides type checking functions (nil?, string?, map?, etc.) and numeric predicates (zero?, pos?, neg?, even?, odd?).
Summary
Functions
Coerces a value to boolean. nil and false are false, everything else is true.
Returns a function that replaces nil first argument with a default value.
Identity function: returns its argument unchanged. Useful as a default function argument or for composition.
Convert collection to set
Returns the type of a value as a keyword.
Convert collection to vector (list)
Functions
Coerces a value to boolean. nil and false are false, everything else is true.
Returns a function that replaces nil first argument with a default value.
Automatically detects arity of the wrapped function and returns a function with matching arity. Supports plain functions and builtin tuples.
Commonly used with update: (update m :count (fnil inc 0)) or
(update m :count (fnil + 0) 5) to provide default values for nil.
Examples
iex> f = PtcRunner.Lisp.Runtime.Predicates.fnil(&Kernel.+/2, 0)
iex> f.(nil, 5)
5
iex> f.(3, 5)
8
iex> f = PtcRunner.Lisp.Runtime.Predicates.fnil(&(&1 + 1), 0)
iex> f.(nil)
1
iex> f.(5)
6
Identity function: returns its argument unchanged. Useful as a default function argument or for composition.
Convert collection to set
Returns the type of a value as a keyword.
Convert collection to vector (list)