Skip to content

Built-ins

A Built-in is always available, with no use, and is the only kind of function a Guard may call. A Script’s own name may shadow one. The rules are in chapter 7.

An argument of the wrong kind raises wrong kind before any work is done, so the entries below list only the other errors each raises (every stdlib function).

The full rules: chapter 7.

min(x, …)

The least of its arguments under <, the first of equal ones; a lone list argument gives the least of its items.

Also raises: out of domain, can't compare.

max(x, …)

The greatest of its arguments under <, the first of equal ones; a lone list argument gives the greatest of its items.

Also raises: out of domain, can't compare.

codePoint(c)

The code point of c, a text of exactly one code point, as a number.

Also raises: out of domain.

fromCodePoint(n)

The text of the code point n, normalised to NFC.

Also raises: out of domain.

upper(s)

s under Unicode full default uppercase mapping, then NFC.

lower(s)

s under Unicode full default lowercase mapping, then NFC.

offset(needle, s)

The Character position where the leftmost match of needle, a text or a Text Pattern, starts in s, or 0 if there is none.

isDisposed(o)

Whether the Host Object o has been disposed.

objectKind(o)

The name of the Object Kind of the Host Object o, as text.

rangeStart(r)

The first end of the range r, as written.

rangeEnd(r)

The second end of the range r, as written.

kindOf(x)

The name of the kind of x, as text, such as "number" or "civil date".

conforms(value, shape)

Whether value fits the Shape shape.

Also raises: invalid shape.

check(value, shape)

value unchanged, if it fits the Shape shape; raises the first mismatch otherwise.

Also raises: invalid shape, not encodable.

explain(value, shape)

The list of every mismatch of value against the Shape shape, empty if it fits.

Also raises: invalid shape.

functionArity(f)

The range of argument counts the Function Value f accepts, from its required parameters to all of them.

functionName(f)

The name of the function the Function Value f was made from, as defined, or Nothing for a Lambda.

offerAvailable(textName)

Whether the current recovery’s retained failure chain has an eligible offer with this Name; false outside recovery or for a malformed or unknown Name.

The full rules: chapter 7.

abs(x)

x without its sign.

floor(x)

The greatest integer at or below x.

ceiling(x)

The least integer at or above x.

truncate(x)

x with its fraction dropped, toward zero.

round(x, places = 0, mode = "half up")

x rounded to places digits after the point, by mode.

Also raises: out of domain.

sqrt(x)

The square root of x.

Also raises: out of domain.

exp(x)

e to the power x.

Also raises: overflow.

ln(x)

The natural logarithm of x.

Also raises: out of domain.

log10(x)

The base-10 logarithm of x.

Also raises: out of domain.

power(x, y)

x to the power y.

Also raises: out of domain, overflow.

sin(x)

The sine of x radians.

cos(x)

The cosine of x radians.

tan(x)

The tangent of x radians.

asin(x)

The arcsine of x, in radians from -pi/2 to pi/2.

Also raises: out of domain.

acos(x)

The arccosine of x, in radians from 0 to pi.

Also raises: out of domain.

atan(x)

The arctangent of x, in radians between -pi/2 and pi/2.

atan2(y, x)

The angle of the point (x, y) from the positive x-axis, in radians above -pi and at most pi.

Also raises: out of domain.

degrees(x)

x radians in degrees.

Also raises: overflow.

radians(x)

x degrees in radians.

random(n)

A whole number from 1 to n, the next from the Script Group’s generator.

Also raises: out of domain.

The full rules: chapter 7.

bitAnd(a, b)

The bits set in both a and b.

Also raises: out of domain.

bitOr(a, b)

The bits set in a, b or both.

Also raises: out of domain.

bitXor(a, b)

The bits set in exactly one of a and b.

Also raises: out of domain.

bitNot(x, width)

x with its low width bits inverted.

Also raises: out of domain.

bitShiftLeft(x, n, width = nothing)

x shifted left n bits, kept to its low width bits when width is given.

Also raises: out of domain, overflow.

bitShiftRight(x, n)

x shifted right n bits, filling with zeros.

Also raises: out of domain.

bitRotateLeft(x, n, width)

The low width bits of x rotated left n places.

Also raises: out of domain.

bitRotateRight(x, n, width)

The low width bits of x rotated right n places.

Also raises: out of domain.

bitCount(x)

How many bits of x are set.

Also raises: out of domain.

bitTest(x, i)

Whether bit i of x is set, bit 0 being the lowest.

Also raises: out of domain.

The full rules: chapter 7.

fromFloat64(b, order = "big")

The number an IEEE 754 binary64 float in the 8 Bytes b holds, as its shortest round-trip decimal.

Also raises: out of domain, can't convert.

fromFloat32(b, order = "big")

The number an IEEE 754 binary32 float in the 4 Bytes b holds, as its shortest round-trip decimal.

Also raises: out of domain, can't convert.

toFloat64(n, order = "big")

The 8 Bytes of the binary64 float nearest n, ties to even.

Also raises: out of domain.

toFloat32(n, order = "big")

The 4 Bytes of the binary32 float nearest n, ties to even.

Also raises: out of domain.

The full rules: chapter 7.

year(d)

The year of the Civil Date d, from 1 to 9999.

month(d)

The month of d, from 1 to 12.

day(d)

The day of the month of d, from 1 to 31.

hour(d)

The hour of the date-time d, from 0 to 23.

Also raises: out of domain.

minute(d)

The minute of the date-time d, from 0 to 59.

Also raises: out of domain.

second(d)

The whole seconds of the date-time d, from 0 to 59.

Also raises: out of domain.

microsecond(d)

The fraction of a second of the date-time d, in whole microseconds from 0 to 999999.

Also raises: out of domain.

weekday(d)

The ISO 8601 day of the week of d, 1 for Monday to 7 for Sunday.

dayOfYear(d)

The day of the year of d, from 1 to 366.

isoWeek(d)

The ISO 8601 week number of d, from 1 to 53.

isoWeekYear(d)

The ISO 8601 week-numbering year of d.

hasTime(d)

Whether the Civil Date d has a time of day.

toCivil(i, offset)

The date-time on the wall clock at the Instant i, at offset from UTC or under the Zone Rules offset.

Also raises: out of domain, out of range.

toInstant(c, offset, disambiguation = nothing)

The Instant at which the wall clock, at offset from UTC or under the Zone Rules offset, reads the date-time c.

Also raises: out of domain, out of range, ambiguous time.

The full rules: chapter 7.

pi = 3.141592653589793238462643383279503

pi, rounded half-even to 34 digits.

newline = U+000A

A line feed, as text.

tab = U+0009

A tab, as text.

quote = U+0022

A double quote, as text.

A Built-in property is read with the <name> of x, or x's <name>. What each gives, and of which kinds, is in chapter 4.

  • the length of x
  • the keys of x
  • the values of x
  • the items of x
  • the lines of x
  • the words of x
  • the characters of x
  • the bytes of x
  • the code points of x
  • the elements of x