RosettaCodeData/Task/Stack/Lang5/stack.lang5

15 lines
404 B
Plaintext

: cr "\n" . ;
: empty? dup execute length if 0 else -1 then swap drop ;
: pop dup execute length 1 - extract swap drop ;
: push dup execute rot append over ;
: s. stack execute . ;
[] '_ set
: stack '_ ;
stack # local variable
1 swap push set
2 swap push set s. cr # [ 1 2 ]
pop . s. cr # 2 [ 1 ]
pop drop
empty? . # -1