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(istuple(list)); // Check that the `tuple` is indeed immutable assert(iserr(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 because it wants to update all changes to subscribers and finds the subscribers by the parent object where
the change is made. Since the parent of a nested
tuple is another
thing holding the
list would not be found.
Another property of
tuples in ThingsDB is that they both are always copies, and not by reference as in most languages. This is
because ThingsDB needs to know which subscribers to update when changes are made.
|choice||Returns a random item from a tuple.|
|filter||Returns a new
|find||Returns the first element that pass a given test.|
|findindex||Returns the index of the first element that pass a given test.|
|indexof||Returns the index of a given value, or
|len||Returns the length of the tuple.|
|map||Returns a new
|reduce||Executes a reducer function on each element, resulting in a single output value.|
|sort||Returns a new sorted
The above methods correspond to those of a
list. For that reason, they are only listed under the data type