Skip to content

Commit 867847c

Browse files
committed
Pop off of array (From #50)
1 parent d0cb48d commit 867847c

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

commands.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ In the format `HEX (char): use`. Things in bold need to be checked in the interp
99
* _23_ (`#`): String to number
1010
* _24_ (`$`): Take object from lower stack up
1111
* _25_ (`%`): Modulous
12-
* _26_ (`&`): **something with maps?**
12+
* _26_ (`&`): Get element from array
1313
* _27_ (`'`): Character literal
1414
* _28_ (`(`): Decrement
1515
* _29_ (`)`): Increment

o.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,10 @@ V toca(ST st,O o){ST ca=newst(o->s.z+1);I p=0;for(;p<o->s.z;++p)psh(ca,newosc(o-
234234

235235
V cmprs(ST st,O o){psh(st,newosc(o->d));dlo(o);} //compress string to array
236236

237-
V key(ST st){O a,b=pop(st);a=top(st);if(b->t==TD&&a->t==TA){I i=b->d;psh(st,dup(a->a->st[i]));dlo(b);}else TE;} //key
237+
V key(ST st){
238+
O b=pop(st);if(b->t==TA){O t=pop(b->a);psh(st,b);psh(st,t);R;}
239+
O a=top(st);if(b->t==TD&&a->t==TA){I i=b->d;psh(st,dup(a->a->st[i]));dlo(b);}
240+
else TE;} //key
238241

239242
S exc(C c){
240243
static S psb; //string buffer

0 commit comments

Comments
 (0)