Arr ::= fn (t :: Type) Type { struct { data : []t; cap : int; } }; arr_add ::= fn(t ::=, a : &Arr(t), x : t) { if a.data.len >= a.cap { a.cap = a.cap * 2 + 2; new_data := new(t, a.cap); new_data.len = a.data.len; for i := 0..a.data.len-1 { new_data[i] = a.data[i]; } a.data = new_data; } a.data.len += 1; a.data[a.data.len-1] = x; }; arr_len ::= fn(t ::=, a : Arr(t)) int { a.data.len };