RosettaCodeData/Task/History-variables/Forth/history-variables.fth
2023-07-01 13:44:08 -04:00

5 lines
232 B
Forth

: history create here cell+ , 0 , -1 , ;
: h@ @ @ ;
: h! swap here >r , dup @ , r> swap ! ;
: .history @ begin dup cell+ @ -1 <> while dup ? cell+ @ repeat drop ;
: h-- dup @ cell+ @ dup -1 = if abort" End of history" then swap ! ;