Built-in Functions
Bonsai has one function namespace. Every built-in is available in every environment without imports, and every function can be called in either form: sum(xs) and xs.sum() are the same call. The first argument is the receiver of the method form.
A host function with the same name as a built-in replaces it for that environment, so built-ins added in later releases never change the meaning of existing expressions. env.listFunctions() returns the same list with signatures and descriptions, for building your own documentation or editor tooling.
Text
toUpperCase toLowerCase trim trimStart trimEnd startsWith endsWith includes indexOf lastIndexOf slice split replace replaceAll padStart padEnd repeat at matches toString toNumber
Lists
map filter find findIndex some every none count flatMap reduce sort sortBy groupBy reverse unique flat first last join slice at includes indexOf lastIndexOf isEmpty min max sum avg
Numbers
round floor ceil trunc abs sqrt clamp toFixed formatNumber formatCurrency min max sum avg
Maps and Values
keys values entries isEmpty type toString
Time
now timestamp duration weeks days hours minutes seconds milliseconds inDays inHours inMinutes inSeconds inMilliseconds year month day hour minute second dayOfWeek startOfDay startOfMonth startOfYear addDays addMonths addYears formatDate abs sum
Not functions
has(...) and try(...) look like calls but are language forms: has inspects a property without reading it and try catches evaluation errors. See let, try, and has. length is a property of strings and lists, not a function: write xs.length.