hana icon indicating copy to clipboard operation
hana copied to clipboard

add fixed length tuples

Open ffwff opened this issue 5 years ago • 0 comments

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.

ffwff avatar May 28 '19 05:05 ffwff