hana
hana copied to clipboard
add fixed length tuples
Tuples (fixed-length arrays) should be added.
Syntax
The syntax for defining a tuple would be:
(a, b)
Which creates a tuple with values a and b.
Tuple destructuring into variables/arguments should be added. The syntax for variables would be:
a, b = (0, 1)
Which would set a to 0, and b to 1.
The syntax for functional arguments should be:
function X((a, b)) begin
return a + b
end
Calling X() with the argument (2, 3) will destructure the tuple into the variables a, b and return the sum 5.
Functions
Tuples can be indexed like arrays and will have map
, filter
and reduce
functions. It should also have an array
function to cast it into an array.
An enumerate
function should also be added for arrays/tuples which will return an array of tuples containing index-value pairs.