Sets consist of any number of elements, where the elements can be of any data type including nested sets.
Sets are coded with elements inside braces and separated with commas, e.g. { ape, bee, cat, dog, elk, fox, gnu, hen }.
Following rules apply:
| Empty sets | Empty sets { } are not the same as blank or void values |
| Mixing data types | A set may contain data of different types, e.g. { 1, Abc, true, date(31.12.2020) } |
| Nesting | Sets support nesting, e.g. { { 1, 2 }, { 3, 4 }, 5 } |
| Nested empty sets | Nested empty sets are allowed. E.g. { {} } is not the same as { } or { { {} } }. |
| Sequence of elements | The sequence of elements is preserved, i.e. {a,b,c,d} and {d,c,b,a} are different. Comparing them with '=' returns true (ordering does not care), but with '==' returns false (elements must be in same order). |
| Mulitple identical elements | Sets may contain multiple identical elements, e.g. { a, b, a, a, c, c }. You can use the trim() function to eliminate duplicates. |
| Embedding | A paramter set can be embedded into another set, e.g. a[] = {1,2}; b[] = {a[]}; Result: b[] contains {{1,2}} |
| Indexing Sets | One element can be extracted by indexing. 1st element begins wtih 0. Example: a[] = {a,b,c,d}{1}; Here, the 1st element is accessed, a[] gets value 'b'. |
| Negative indexing | Negative indexing supported here. a[] = { a,b,c,d,e }{-2} assigns 'd' to a[]. |
| Slicing Sets | Specify multiple index values and ranges to extract subsets. |
| Arithmetics | A broad range of arithmetic operators are available to manipulate sets, for example intersections and unions. |
| Assignments | Assignments are possible on individual elememnts in existing sets, see assignments into sets. |
a[] = { 1, a, 2, {b,c}, true, date(today) };
echo( a[], " / ", type(a[]) );
echo( "First element: ", a[]{0}, " and last element: ", a[]{1} );{1,'a',2,{'b','c'},true,'2025-09-21'} / set
First element: 1 and last element: a