All nested arrays are immutable and thus tuples.
list = ; list.push(['this list will be nested and therefore convert to a tuple']); // Check that the first item in `list` is indeed a `tuple` assert(is_tuple(list)); // Check that the `tuple` is indeed immutable assert(is_err(try(list.push('cannot be added to a tuple'))));
tuple only becomes a
tuple when it is nested inside another
list, which means the
tuple will be immutable.
ThingsDB does this to make watching things possible; it wants to update all changes within a thing to the subscribers that are watching, and finds them by thing. Since the parent of a nested
tuple is another
list, the watched
thing holding the
listwith nested lists would not be found.
Another property of
tuples in ThingsDB is that they both are always copies, and not a reference as in most languages. This is also done to enable watching.
|choice||Return a random item from a tuple.|
|each||Iterate over all items in a tuple.|
|every||Check if all items pass a given test.|
|filter||Return a new
|find||Return the first item that pass a given test.|
|find_index||Return the index of the first item that pass a given test.|
|index_of||Return the index of a given value, or
|join||Returns a string with all items joined.|
|len||Return the length of the tuple.|
|map||Return a new
|reduce||Execute a reducer function on each item, resulting in a single output value.|
|reverse||Return a new list with the items in reverse order.|
|some||Check if at least one item passes a given test.|
|sort||Return a new sorted
The above functions correspond to those of a
list. For that reason, they are only listed under the data type