PtcRunner.Lisp.Eval.Where (PtcRunner v0.9.0)

Copy Markdown View Source

Where predicates and comparison helpers for Lisp evaluation.

Handles building predicates for filtering operations and comparison logic.

Summary

Functions

Builds a field accessor function from a field path AST node.

Builds a predicate combinator function (:all_of, :any_of, :none_of).

Builds a predicate function for where expressions.

Checks if a value is truthy (not nil or false).

Functions

build_field_accessor(arg)

@spec build_field_accessor({:field, list()}) :: (map() -> term())

Builds a field accessor function from a field path AST node.

build_pred_combinator(atom, fns)

@spec build_pred_combinator(atom(), [(map() -> boolean())]) :: (map() -> boolean())

Builds a predicate combinator function (:all_of, :any_of, :none_of).

build_where_predicate(atom, accessor, value)

@spec build_where_predicate(atom(), (map() -> term()), term()) :: (map() -> boolean())

Builds a predicate function for where expressions.

truthy?(arg1)

@spec truthy?(term()) :: boolean()

Checks if a value is truthy (not nil or false).

Examples

iex> PtcRunner.Lisp.Eval.Where.truthy?(nil)
false

iex> PtcRunner.Lisp.Eval.Where.truthy?(false)
false

iex> PtcRunner.Lisp.Eval.Where.truthy?(0)
true

iex> PtcRunner.Lisp.Eval.Where.truthy?("hello")
true