puti ::= fn(x: int) { #C("printf(\"%ld\\n\", (long)x); "); }; // putf ::= fn(x: float) { // #C("printf(\"%f\\n\", (double)x); // "); // }; Arr ::= fn (t :: Type) Type { struct { data : []t; len, cap : int; } }; arr_add ::= fn(t :: Type, a : &Arr(t), x : t) { if a.len >= a.cap { a.cap = a.cap * 2 + 2; new_data := new(t, a.cap); each i := 0..a.len-1 { new_data[i] = a.data[i]; } a.data = new_data; } a.data[a.len] = x; a.len += 1; }; main ::= fn() { arr : Arr(int); each i := 1..100 { arr_add(int, &arr, i*i); } each i := 0..arr.len - 1 { puti(arr.data[i]); } };