summaryrefslogtreecommitdiff
path: root/a.toc
diff options
context:
space:
mode:
Diffstat (limited to 'a.toc')
-rw-r--r--a.toc28
1 files changed, 28 insertions, 0 deletions
diff --git a/a.toc b/a.toc
new file mode 100644
index 0000000..60c31dd
--- /dev/null
+++ b/a.toc
@@ -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