diff options
Diffstat (limited to 'array.c')
-rw-r--r-- | array.c | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -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 |