RosettaCodeData/Task/Stack/Forth/stack.fth
Ingy döt Net 68f8f3e56b all tasks
2013-04-11 01:07:29 -07:00

15 lines
311 B
Forth

: stack ( size -- )
create here cell+ , cells allot ;
: push ( n st -- ) tuck @ ! cell swap +! ;
: pop ( st -- n ) -cell over +! @ @ ;
: empty? ( st -- ? ) dup @ - cell+ 0= ;
10 stack st
1 st push
2 st push
3 st push
st empty? . \ 0 (false)
st pop . st pop . st pop . \ 3 2 1
st empty? . \ -1 (true)