WAL Programmer Manual

0.6.2a

6. Arrays

This section describes array functions. In WAL, arrays are a hashmap data structure.
(array (id expr)*) ↦ (array)
  id : WAL value
  expr : WAL expression
  
Constructs an array initialized with the data passed as tuples to this function. Keys are always stored as strings. When printed, arrays are shown in curly braces {} and the entries are shown in parentheses ().
Examples
>-> (array)
{}
>-> (array ['x 10] ['y 20])
{("x" 10) ("y" 20)}
>-> (array [5 5])
{("5" 5)}
(seta array key+ value) ↦ WAL value
  array : (array)
  key : WAL value
  value: WAL expression
  
Combines the keys and inserts/updates value in array.
Examples
>-> (seta (array) 'x 10)
{("x" 10)}
>-> (seta (array ['x 10]) 'y 20)
{("x" 10) ("y" 20)}
>-> (set [some-array (array)])
>-> (set [data ("test")])
>-> (seta some-array 0 data)
{("0" "test")}
>-> (seta (array) 'x 'y 10)
{("x-y" 10)}
(geta array key+) ↦ WAL value
  array : (array)
  key : WAL value
  
Combines the keys and looks up the entry in array.
Examples
>-> (geta (array ['x 10]) 'x)
10
>-> (seta (array ["x-y" 20]) 'x 'y)
20