From abfea518adf24b5f2a6245ba37e068bfe97152ce Mon Sep 17 00:00:00 2001
From: Leo Tenenbaum <pommicket@gmail.com>
Date: Sat, 25 Jan 2020 22:32:59 -0500
Subject: seem to have fully fixed packages

---
 std/arr.toc | 18 +++++++-----------
 1 file changed, 7 insertions(+), 11 deletions(-)

(limited to 'std')

diff --git a/std/arr.toc b/std/arr.toc
index 0e81f3a..12d44f5 100644
--- a/std/arr.toc
+++ b/std/arr.toc
@@ -4,24 +4,20 @@ pkg "arr";
 #export Arr ::= fn (t :: Type) Type {
 	struct {
 		   data : []t;
-		   len, cap : int;
+		   cap : int;
 	}
 };
 #export arr_add ::= fn(t ::=, a : &Arr(t), x : t) {
-		if a.len >= a.cap {
+		if a.data.len >= a.cap {
 		   a.cap = a.cap * 2 + 2;
 		   new_data := new(t, a.cap);
-		   for i := 0..a.len-1 {
+		   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[a.len] = x;
-		a.len += 1;
-};
-
-#export arr_foreach ::= fn(t ::=, a : Arr(t), f : fn(&t)) {
-		for i := 0..a.len-1 {
-			 f(&a.data[i]);
-		}
+		a.data[a.data.len] = x;
+		a.data.len += 1;
 };
+#export arr_len ::= fn(t ::=, a : Arr(t)) int { a.data.len };
-- 
cgit v1.2.3