Built-in Symbols¶
FuncScript registers every built-in helper under the symbols documented below. Symbol lookup is case-insensitive, so the canonical names listed here can be written in any casing. Wherever an operator has both infix and function-call forms, you can use either (1 + 2 or +(1, 2)).
Arithmetic Operators¶
+,-,*,/,%– Standard arithmetic on integers, long integers, and floats. Pure integer chains stay integral as long as each division is exact; otherwise values promote to floating point automatically.div– Integer-only division; accepts only 32/64-bit integers (or their long forms) and truncates toward zero. Mixing with non-integers raises a type mismatch error.- value– Unary negation for numeric values.
Comparison & Membership¶
=,==,!=,<,<=,>,>=– Comparisons returningBooleanvalues (==is an alias for=).value in list– Membership test for lists (for strings useContains(text, substring)).
Null & Safe Access Operators¶
value ?? fallback– Returnsfallbackwhenvalueis null.kvc?.key– Safe member access; returns null when the target is null or the key is missing (errors when the target is not a record).test-val?!expr– Evaluatesexpriftest-valis not null; otherwise, defaults to null. This is typically used whenexprdepends on a non-nulltest-val.kvc.key– Direct member access (returns null for missing keys; errors on null targets and non-records).
Logical & Control Flow¶
if condition then value else other– Branching expression (keywords are required).a and b/a or b– Logical conjunction/disjunction with short-circuit evaluation.! value– Logical negation.switch selector, match1: result1, match2: result2, defaultResult– Switch over a selector; eachmatch: resultarm is compared to the selector and the first match wins. Add an optional trailing default value (without:) to return when no match occurs.case condition: result– Conditional helper written withcondition: resultpairs separated by commas or semicolons; add atrue: fallbackarm or a trailing default value (case cond: value, fallback) for defaults.
Numeric Functions¶
All numeric helpers belong to the math provider collection, so you can call them either directly (Sqrt(9)) or via the namespace-style accessor (math.Sqrt(9)). Aliases such as Ceil and log also work under the math scope.
math.Abs(number)(Abs) – Absolute value.math.Ceiling(number)(Ceiling, aliasmath.Ceil) – Smallest integer greater than or equal tonumber.math.Floor(number)(Floor) – Largest integer less than or equal tonumber.math.Round(number, digits?)(Round) – Round to the nearest integer or todigitsdecimals.math.Trunc(number)(Trunc) – Drop the fractional component.math.Sign(number)(Sign) – Return-1,0, or1.math.Clamp(value, min, max)(Clamp) – Constrain to a range.math.Min(value1, value2, ...)/math.Max(...)(Min/Max) – Extremes across numeric arguments.math.Pow(base, exponent)(Pow, aliasmath.Power, operator^) – Raisebasetoexponentor chain powers (2 ^ 3 ^ 2).math.Sqrt(number)/math.Cbrt(number)(Sqrt/Cbrt) – Square or cube roots.math.Exp(number)(Exp) – Euler's number raised tonumber.math.Ln(number, base?)(Ln, aliasmath.log) – Natural logarithm, with optional custom base.math.Log10(number)/math.Log2(number)(Log10/Log2) – Base-10 or base-2 logarithms.math.Sin(number)/math.Cos(number)/math.Tan(number)(Sin/Cos/Tan) – Trigonometric functions (radians).math.Asin(number)/math.Acos(number)/math.Atan(number)(Asin/Acos/Atan) – Inverse trigonometric functions.math.Atan2(y, x)(Atan2) – Two-argument arctangent preserving quadrant information.math.Sinh(number)/math.Cosh(number)/math.Tanh(number)(Sinh/Cosh/Tanh) – Hyperbolic trig functions.math.Asinh(number)/math.Acosh(number)/math.Atanh(number)(Asinh/Acosh/Atanh) – Inverse hyperbolic trig functions.math.DegToRad(degrees)/math.RadToDeg(radians)(DegToRad/RadToDeg, aliasesdeg2rad/rad2deg) – Convert angles.math.Random(seed)(Random) – Deterministic pseudo-random double in[0, 1)derived fromseed.- Constants exposed via provider collections are accessed without parentheses (e.g.,
math.Pi).
List & Sequence Helpers¶
list map (value, index) => ...– Transform each element.list filter (value, index) => ...– Keep elements that satisfy the predicate.list reduce (acc, value) => ... ~ seed– Accumulate a list into a single value.Range(start, count)(Series) – Produce[start, start+1, ...]withcountelements;startmay be any numeric type and controls the output element type, whilecountis coerced to an integer by truncating toward zero.Distinct(list)– Remove duplicate values while preserving order.Any(list, predicate)– Returnstruewhen any element satisfiespredicate.Contains(listOrText, value)– Returnstruewhenvalueis present (lists) orvalueis a substring (strings, case-insensitive).First(list, predicate)– Returns the first element that matchespredicate(or null when none match).Len(value)(Length) – Length of the list or string;nullreturns0; any other scalar returns1.Take(list, count)/Skip(list, count)– Subset operators.Sort(list)– Sort values using default comparison.Reverse(list)– Reverse the order of elements.
Key-Value & Record Helpers¶
- Member access uses dot syntax (
record.key). For selecting a subset of fields, see the selector syntax described in Syntax.
Text & Formatting¶
text.upper(text)– Converttextto uppercase (culture invariant).text.lower(text)– Converttextto lowercase (culture invariant).join(list, separator)– Concatenate list entries withseparator.format(value, format?)– Convertvalueto a string;formatcan be a numeric pattern like"#,0.00"or the special"json"mode.find(text, value, startIndex?)– Return the zero-based index ofvalueor-1if not found.regex(text, pattern, flags?)– Returnstruewhenpatternmatchestext; optionalflagsaccepts characters such asi,m,s, orxto toggle regex options.substring(text, start, length?)– Slice fromtextstarting atstartwith optionallength.endswith(text, suffix)– Returnstruewhentextends withsuffix.isBlank(value)– Returnstruewhen a string is null, empty, or whitespace.parse(text, format?)– Parsetextusing helpers like"hex","l"(int64), or"fs"(nested FuncScript)._templatemerge(value1, value2, ...)– Internal templating helper that flattens values (lists or scalars) into a single string.HEncode(text)– HTML-encodetext.
Date & Time¶
Date(text, format?)– Parse a date string, optionally with a custom .NET format string.TicksToDate(ticks)– Convert .NET ticks (int64) to aDateTimevalue.
File & OS Helpers¶
file(path)– Read a file as text.isfile(path)– Returnstruewhen a path points to a file.fileexists(path)– Returnstruewhen a path exists and is a file.dirlist(path)– Return the entries inside a directory.
Diagnostics & Miscellaneous¶
log(value, messageOrHandler?)– Returnsvalueafter writing either the formatted value (when the second argument is omitted) or the providedmessageOrHandleroutput. When a handler function is supplied it is invoked withvalue.error(message)– Constructs anErrorvalue. Most built-in functions propagate anErrorresult, which aborts evaluation when consumed without handling.
Values & Constants¶
math.Pi– π constant.math.E– Euler's constant.