diff options
author | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-14 01:06:14 +0000 |
---|---|---|
committer | Peter Mikkelsen <petermikkelsen10@gmail.com> | 2022-01-14 01:06:14 +0000 |
commit | 396543790dc1c844c726b77a95c6180978232abd (patch) | |
tree | b5051f5afba137e499b883b637ce6fc436805ec5 /array.c | |
parent | 07082593ab4abfbf9a3dd6729cb2e548ec303115 (diff) |
Add each (ยจ) operator
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 |