DocsBuilt-in functions
Lists and tables
A list keeps values in order, counted from 1. A table finds values by their keys.
$list
$list[a;b;c...]
A list of values.
$let[fruit;$list[apple;pear;plum]]
$print[$count[$get[fruit]] fruit, first $item[$get[fruit];1]]3 fruit, first apple
$table
$table[key;value;key;value...]
A table: values found by their keys.
$let[prices;$table[apple;2;pear;3]]
$print[A pear costs $item[$get[prices];pear]]A pear costs 3
$item
$item[list;number] or $item[table;key]
An item of a list (the first is 1) or the value of a key of a table.
$let[days;$list[Mon;Tue;Wed]]
$print[$item[$get[days];2]]
$print[$item[$get[days];9]]Tue nil
$count
$count[list]
How many items a list or table has, or how many letters a text has.
$print[$count[$list[1;2;3]]]
$print[$count[hello]]3 5
$contains
$contains[list;value]
true when the list holds the value, the table has the key, or the text holds the other text.
$let[bag;$list[key;map]]
$print[$contains[$get[bag];key]]
$print[$contains[hello world;world]]true true
$keys
$keys[table]
A list of the keys of a table.
$let[stock;$table[apples;4;pears;0]]
$print[$keys[$get[stock]]][apples; pears]
$add
$add[list;value]
Puts a value at the end of a list.
$let[queue;$list[]]
$add[$get[queue];Ana]
$add[$get[queue];Ben]
$print[$get[queue]][Ana; Ben]
$insert
$insert[list;number;value]
Puts a value into a list at a place (the first is 1); a table gets the key.
$let[queue;$list[Ana;Ben]]
$insert[$get[queue];1;Cy]
$print[$get[queue]][Cy; Ana; Ben]
$remove
$remove[list] or $remove[list;number]
Takes the last item (or the one at a place, or a table's key) out and gives it.
$let[stack;$list[a;b;c]]
$print[Took $remove[$get[stack]]]
$print[Left $get[stack]]Took c Left [a; b]
$sort
$sort[list] or $sort[list;key]
A sorted copy of a list (numbers small to big, then text A to Z); with a key, a list of tables sorted by that key.
$print[$sort[$list[5;1;3]]]
$let[team;$list[$table[name;Zoe;age;30];$table[name;Al;age;25]]]
$each[p;$sort[$get[team];age]]
$print[$get[p.name]]
$endeach[1; 3; 5] Al Zoe
$reverse
$reverse[list]
A copy of a list (or a text) the other way round.
$print[$reverse[$list[1;2;3]]]
$print[$reverse[stressed]][3; 2; 1] desserts
$slice
$slice[list;from] or $slice[list;from;to]
Part of a list or a text, from one place up to another (the first is 1, -1 is the last).
$let[n;$list[1;2;3;4;5]]
$print[$slice[$get[n];2;4]]
$print[$slice[Najova;1;3]][2; 3; 4] Naj