A-M baby
This commit is contained in:
parent
764da6cbbb
commit
db842d013d
19005 changed files with 197040 additions and 7 deletions
|
|
@ -0,0 +1,13 @@
|
|||
: checked-array
|
||||
CREATE ( size -- ) DUP , CELLS ALLOT
|
||||
DOES> ( i -- a+i )
|
||||
2DUP @ 0 SWAP WITHIN IF
|
||||
SWAP 1+ CELLS +
|
||||
ELSE
|
||||
1 THROW
|
||||
THEN ;
|
||||
|
||||
8 checked-array myarray
|
||||
|
||||
: safe-access ( i -- a[i] )
|
||||
['] myarray CATCH 1 = IF ." Out of bounds!" 0 THEN ;
|
||||
Loading…
Add table
Add a link
Reference in a new issue