ArrayLang

Download: version 0.4 zip file

Examples

#product of a vector def prod(data) = reduce( op.mult, data) #factorial let fact = @(n) prod(1:n)

Primitive Types

typeexampleoperators
number 7, -3.14 == ~= + - * / < > >= <=
boolean true, false == ~= ~ || &&
string "whistle" ==
row [1 2 3], 1:10 == ~= + - * / .+ .- .* ./ < > >= <=
col [1 2 3]', (1:10)' == ~= + - * / .+ .- .* ./ < > >= <=
tuple (1,"hello", true)

Function Definition

def fn_name (arg1, ..., argn ) = expr

Variable Definition

let pattern = expr

Anonymous Functions

@(arg1, ..., argn ) expr

Local Bindings

let pattern = expr in expr

Pattern Matching

let tuple_pattern = tuple in expr
let _ = expr in expr

Sequence of expressions

expr1; ...; exprn

Control Flow

if test then expr if test then trueExpr else falseExpr

Array Constructor

[ expr1 expr2 ... exprn ]

Array Range Constructor

exprLower : exprUpper
exprLower : exprUpper by stride

Array Concatenation

array1 ++ array2

Tuples

expr1, ..., exprn

Functional For-Loop Array Construction

for pattern in expr do expr

Features Not Yet Type-Checkable

Container patterns

let [array_pattern] = array in expr
let {list_pattern} = list in expr

Overloading

let id = generic(overload1, overload2)


Planned Features

Array Slicing

let A = [1:5 21:25] let B = A(1, 1:3) # [1 2 3] let C = A(2,:) # [21 22 23 24 25]

Window For-Loop Array Construction

for window id[size] in array do expr

Element-wise For-Loop Array Construction

for each pattern in array do expr

Partial Function Application

def f(x,y) = x + y let plusOne = f(1, _)

Match Statements

match expr with
pattern_1 -> expr_1
...
| pattern_n -> expr_n
end

Tagged Unions

type name (type_args) = CName_1 of typeExpr1 ... | CName_n of typeExpr_n