summaryrefslogtreecommitdiff
path: root/array.c
diff options
context:
space:
mode:
Diffstat (limited to 'array.c')
-rw-r--r--array.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/array.c b/array.c
index a2afc44..4a14ab9 100644
--- a/array.c
+++ b/array.c
@@ -78,4 +78,23 @@ scalarextend(Array *a, Array *b, Array **aa, Array **bb)
}else
return 0;
return 1;
+}
+
+Array *
+arrayitem(Array *a, int index)
+{
+ Array *res = nil;
+ switch(a->type){
+ case AtypeInt:
+ res = mkscalarint(a->intdata[index]);
+ break;
+ case AtypeArray:
+ res = a->arraydata[index];
+ incref(res);
+ break;
+ default:
+ print("Unhandled case in arrayitem()\n");
+ exits(nil);
+ }
+ return res;
} \ No newline at end of file