diff options
Diffstat (limited to 'a.toc')
-rw-r--r-- | a.toc | 28 |
1 files changed, 28 insertions, 0 deletions
@@ -0,0 +1,28 @@ +// array package +pkg "a"; + +#export Arr ::= fn (t :: Type) Type { + struct { + data : []t; + len, cap : int; + } +}; +/* +#export arr_add ::= fn(t ::=, 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; +}; + +#export arr_foreach ::= fn(t ::=, a : Arr(t), f : fn(&t)) { + each i := 0..a.len-1 { + f(&a.data[i]); + } +};*/
\ No newline at end of file |