Predicator.Functions.SystemFunctions (predicator v3.4.0)
View SourceBuilt-in helper functions for use in predicator expressions.
This module provides a collection of utility functions that can be called within predicator expressions using function call syntax. These functions operate on values from the evaluation context and return computed results.
Available Functions
String Functions
len(string)
- Returns the length of a stringupper(string)
- Converts string to uppercaselower(string)
- Converts string to lowercasetrim(string)
- Removes leading and trailing whitespace
Examples
iex> Predicator.Functions.SystemFunctions.call("len", ["hello"])
{:ok, 5}
iex> Predicator.Functions.SystemFunctions.call("upper", ["world"])
{:ok, "WORLD"}
iex> Predicator.Functions.SystemFunctions.call("unknown", [])
{:error, "Unknown function: unknown"}
Summary
Functions
Returns all system functions as a map in the format expected by the evaluator.
Types
@type function_result() :: {:ok, Predicator.Types.value()} | {:error, binary()}
Functions
@spec all_functions() :: %{required(binary()) => {non_neg_integer(), function()}}
Returns all system functions as a map in the format expected by the evaluator.
Returns
A map where keys are function names and values are {arity, function}
tuples.
Examples
iex> functions = Predicator.Functions.SystemFunctions.all_functions()
iex> Map.has_key?(functions, "len")
true
iex> {arity, _function} = functions["len"]
iex> arity
1