Skip to content

Built-in Functions

OperatorDescriptionExampleResult
+Add+3 47
-Subtract-10 37
*Multiply*3 412
/Divide/10 25
%Modulo%10 31
OperatorDescriptionExampleResult
==Equal==a btrue/false
!=Not equal!=a btrue/false
>Greater than>a btrue/false
<Less than<a btrue/false
>=Greater or equal>=a btrue/false
<=Less or equal<=a btrue/false
OperatorDescriptionExample
&Logical AND&a b
|Logical OR|a b
!Logical NOT!a
FunctionSignatureDescriptionExample
catt t > tConcatenate two stringscat "hello" " world""hello world"
lent > nString lengthlen "hello"5
trmt > tTrim whitespacetrm " hi ""hi"
splt t > L tSplit string by delimiterspl "a,b,c" ","["a","b","c"]
hast t > bCheck if string contains substringhas "hello" "ell"true
rgxt t > L tRegex match (returns captures)rgx "abc123" "[0-9]+"["123"]
fmtt ... > tFormat string with valuesfmt "{} is {}" "sky" "blue"
FunctionAliasSignatureDescriptionExample
lenlengthL _ > nList lengthlen [1,2,3]3
hdheadL _ > _First elementhd [1,2,3]1
tltailL _ > L _All elements except firsttl [1,2,3][2,3]
revreverseL _ > L _Reverse a listrev [1,2,3][3,2,1]
srtsortL _ > L _Sort a listsrt [3,1,2][1,2,3]
srtsortfn L _ > L _Sort by key functionsrt cmp xs
slcsliceL _ n n > L _Slice (start, end)slc [1,2,3,4] 1 3[2,3]
flatflattenL L _ > L _Flatten nested listsflat [[1,2],[3]][1,2,3]
unquniqueL _ > L _Remove duplicatesunq [1,2,2,3][1,2,3]
hascontainsL _ _ > bCheck if list contains elementhas [1,2,3] 2true
FunctionAliasSignatureDescriptionExample
mapfn L _ > L _Apply function to each elementmap dbl [1,2,3]
fltfilterfn L _ > L _Keep elements where function returns trueflt pos [1,-2,3]
fldfoldfn _ L _ > _Reduce list to single valuefld add 0 [1,2,3]
grpgroupfn L _ > M t L _Group elements by function resultgrp cat xs
FunctionSignatureDescriptionExample
sumL n > nSum a list of numberssum [1,2,3]6
avgL n > nAverage of a list of numbersavg [2,4,6]4
FunctionSignatureDescriptionExample
mmap> MCreate empty mapm=mmap
mgetM t > _Get value by keymget m "key"
msetM t _ > MSet key-value pairmset m "key" val
mhasM t > bCheck if key existsmhas m "key"
mkeysM > L tGet all keysmkeys m
mvalsM > L _Get all valuesmvals m
mdelM t > MRemove key, return new mapmdel m "key"
FunctionSignatureDescriptionExample
str_ > tConvert to stringstr 42"42"
numt > nParse string to numbernum "42"42
absn > nAbsolute valueabs -55
flrn > nFloorflr 3.73
celn > nCeilingcel 3.24
rndn n > nRound to N decimal placesrnd 3.14159 23.14
FunctionSignatureDescriptionExample
gett > R t tHTTP GET (returns Result)get "https://..."
$t > R t tHTTP GET shorthand (sugar for get)$"https://..."
postt t > R t tHTTP POST (url, body)post url body
gett M > R t tHTTP GET with headersget url headers
postt t M > R t tHTTP POST with headerspost url body headers
rdt > R t tRead filerd "data.txt"
rdt t > R t tRead file with formatrd "data.csv" "csv"
wrt t > R t tWrite file (path, content)wr "out.txt" data
wrt t t > R t tWrite file with formatwr "out.json" data "json"
envt > R t tRead environment variableenv "API_KEY"

Note: $ is syntactic sugar -$url compiles to get url. HTTP builtins (get, $, post) require the native binary; they are not available in the npm/WASM build.

FunctionSignatureDescriptionExample
rdbt t > R _ tParse data (format: "json", "csv")rdb data "json"
jptht t > R t tExtract JSON pathjpth data "users.0.name"
jdmp_ > tDump value as JSON stringjdmp [1,2,3]
jpart > R _ tParse JSON string to valuejpar '{"a":1}'
FunctionSignatureDescriptionExample
prnt_ > _Print value and return itprnt "hello"
FunctionSignatureDescriptionExample
now> nCurrent Unix timestamp (seconds)now

Any function returning R (Result) can be called with ! to auto-unwrap:

ilo
r=$url -- r is R t t (Result)
v=$!url -- v is t (auto-unwrapped, propagates error)
data=rdb! r "json" -- auto-unwrap parse result

See Error Handling for full details on !, ?, ??, and Result types.

Access list elements and record fields with .:

ilo
xs.0 -- first element of list xs
xs.2 -- third element
user.name -- field "name" of record/map
data.users.0 -- chained access

Safe navigation with .? returns nil instead of erroring on missing keys:

ilo
user.?email -- nil if "email" doesn't exist

All builtins accept long-form names that resolve to the canonical short form. ilo will emit a hint suggesting the short form:

Long formShort form
lengthlen
headhd
tailtl
reverserev
sortsrt
sliceslc
uniqueunq
filterflt
foldfld
flattenflat
concatcat
containshas
groupgrp
averageavg
printprnt
trimtrm
splitspl
formatfmt
regexrgx
readrd
writewr
readbufrdb
floorflr
ceilcel
roundrnd
stringstr
numbernum