Skip to main content

Built-in functions

Built-ins are called by name in expressions. Their names cannot be used for user function declarations.

FunctionAccepted inputResultBehavior
abs(x)int or floatSame scalar typeAbsolute value
sqrt(x)floatfloatSquare root
min(a, b)Numeric scalarsfloat if either input is float, otherwise intMinimum
max(a, b)Numeric scalarsfloat if either input is float, otherwise intMaximum
len(a)Numeric arrayintNumber of elements
sum(a)Numeric arrayScalar element typeOrdered sum

Examples​

show abs(-7)
show abs(-3.5)
show sqrt(9.0)
show min(2, 3.5)
show max(2.0, 3)
show len([1, 2, 3])
show sum([1, 2, 3])
Output
7
3.5
3
2
3
3
6

Edge cases​

  • sqrt requires an actual float argument: sqrt(9) is a type error; use sqrt(9.0).
  • sqrt of a negative float produces NaN.
  • Floating min and max lower to C fmin and fmax. With one NaN argument and one numeric argument, they return the numeric value.
  • abs of the minimum signed integer fails because its positive value cannot fit in the current integer representation.
  • Integer sum checks every addition for overflow.
  • len still evaluates its array argument, so it does not suppress failures in an expression that constructs the array.

Show​

show expression is a statement, not a function call. It accepts integer, float, or boolean scalars and prints a trailing newline. See output formatting.

There is no standard library module/import system, input function, or file I/O API in the current language.