Predicator.Functions.SystemFunctions (predicator v3.4.0)

View Source

Built-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 string
  • upper(string) - Converts string to uppercase
  • lower(string) - Converts string to lowercase
  • trim(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

function_result()

@type function_result() :: {:ok, Predicator.Types.value()} | {:error, binary()}

Functions

all_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