# `PtcRunner.Lisp.Runtime.Predicates`
[🔗](https://github.com/andreasronge/ptc_runner/blob/main/lib/ptc_runner/lisp/runtime/predicates.ex#L1)

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?).

# `associative?`

# `boolean`

Coerces a value to boolean. nil and false are false, everything else is true.

# `boolean?`

# `char?`

# `coll?`

# `comp_variadic`

Composes functions right-to-left. Zero args returns identity.
The rightmost function can accept multiple arguments; all others receive a single value.

# `complement`

Returns a function that returns the boolean opposite of `f`.

# `constantly`

Returns a function that always returns `value`, ignoring any arguments.

# `counted?`

# `decimal?`

# `distinct_args?`

# `double?`

# `even?`

# `every_pred_variadic`

Returns a function that checks all values against each predicate.
Short-circuits on first falsy result. Always returns true/false.

# `false?`

# `float?`

# `fn?`

# `fnil`

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`

Identity function: returns its argument unchanged.
Useful as a default function argument or for composition.

# `ifn?`

# `indexed?`

# `infinite?`

# `int?`

# `integer?`

# `keyword`

Coerces a string to keyword. Returns keyword unchanged. Returns nil for nil.

Validates that the string matches PTC-Lisp keyword character set
(letters, digits, `-`, `_`, `?`, `!`; must start with a letter).
No `/` (per DIV-13), no spaces, no empty strings, no operator chars.

Routes the name through `PtcRunner.Lisp.SourceAtoms.intern/1`: names in
the bounded vocabulary become atoms, every other name becomes a
`%PtcRunner.Lisp.Keyword{}` struct. This never grows the BEAM atom table
from arbitrary runtime strings.

- `(keyword "foo")` returns the keyword `:foo` — a `%PtcRunner.Lisp.Keyword{}`
  struct for names outside the bounded vocabulary
- `(keyword :bar)` returns `:bar`
- `(keyword nil)` returns `nil`
- `(keyword "")` raises error
- `(keyword "foo/bar")` raises error (violates DIV-13)

# `keyword?`

# `map?`

# `map_entry?`

# `nan?`

# `nat_int?`

# `neg?`

# `neg_int?`

# `nil?`

# `not_`

# `number?`

# `odd?`

# `partial_variadic`

Returns a function with some arguments pre-filled.
`(partial f a b)` returns a function that calls `f` with `a`, `b`, plus any additional args.

# `pos?`

# `pos_int?`

# `ratio?`

# `rational?`

# `regex?`

# `reversible?`

# `seq?`

# `seqable?`

# `sequential?`

# `set`

Convert collection to set

# `set?`

# `some?`

# `some_fn_variadic`

Returns a function that checks all values against each function.
Short-circuits on first truthy result, returning the actual value (not boolean).

# `sorted?`

# `string?`

# `symbol?`

# `true?`

# `type_of`

Returns the type of a value as a keyword.

# `vec`

Convert collection to vector (list)

# `vector?`

# `zero?`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
