Built-in Symbols¶
FuncScript registers every built-in helper under the symbols documented below. The names are case-sensitive and match how you call them inside scripts. 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 listOrText– Membership test for lists and strings.
Null & Safe Access Operators¶
value ?? fallback– Returnsfallbackwhenvalueis null.kvc?.key– Safe member access; returns null when the target or key is missing.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 (throws on missing keys or 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.not value– Logical negation (alias:!value).switch selector, condition1: result1, condition2: result2, defaultCondition: defaultResult– Switch over a selector; commas or semicolons separate branches.case condition: result– Case helper written withcondition: resultpairs separated by commas or semicolons; add atrue: fallbackarm 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()(Random) – Random double in[0, 1).- 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)– Produce[start, start+1, ...]withcountelements.Distinct(list)– Remove duplicate values while preserving order.Any(list, predicate)– Returnstruewhen any element satisfiespredicate.Contains(list, value)– Returnstruewhenvalueis present.First(list)– First element (errors on empty lists).Len(list)– Length of the list.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(pattern, value1, value2, ...)– Composite formatting using .NET format strings.find(text, value)– 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¶
guid()– Generate a GUID string.log(value, messageOrHandler?)– Returnsvalueafter optionally printingmessageOrHandleror, when it is a function, invoking it 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.
More constants will surface here as provider collections grow.