a = {} – create a table
a['hello'] = 1 – map string "hello" to 1
print(a['hello']) – print the value of the mapping of 'hello' in 'a'
a[2] = 123 – map int 2 to 123
print(a[2])
#break
#case {value} {true body}
#continue
#default {body}
#else
#elseif {expression} {true body}
#if {expression} {true body}
#for {{min} {variable} {max}} {body}
#return {value}
#switch {expression} {body}
#while {expression} {body}
Right now #var {bla[x][y][z]} {hello world} creates an associative array.
Now I thought it'd be cool if numbers could be used as well, so $bla[x][y][z] could also be written as $bla[1][1][1] -> assuming x y and z are the first elements. That is:
#var {bla[x][y][y]} {hello world y}
#var {bla[x][y][z]} {hello world z}
Now $bla[1][1][1] would be the equivalent of $bla[x][y][y] and $bla[1][1][2] the equivalent of $bla[x][y][z]
The problem is that I also want people to use numbers, so one could enter: #var bli[22] hello world, but to access this you'd need to use: $bli[1] rather than $bla[22] (which would look for the 22nd element) which is rather unintuitive.
One possible solution I was thinking of is having people use + for indexing, so bli[+1] is used for the first element, and bli[-1] would be used for the last element. This assuming negative numbers are rarely used in associative arrays.
Is there a better solution for this problem?