mirror of
https://github.com/russolsen/cloforth
synced 2024-11-16 19:48:23 +01:00
42 lines
645 B
Text
42 lines
645 B
Text
|
|
; Create the : word which is a shortcut for
|
|
; defining other word. Use : like this
|
|
; : <word> [ <<defintion>> ]
|
|
compile [ gettok compile rot set! ] ':' set!
|
|
|
|
: true [ 1 1 = ]
|
|
|
|
: false [ 1 0 = ]
|
|
|
|
; Print the top of the stack and pop it off
|
|
: . [ print drop ]
|
|
|
|
; Print a newline
|
|
: nl [ 10 char . ]
|
|
|
|
; Print the top of the stack followed by a newline
|
|
: .nl [ . nl ]
|
|
|
|
: space [ ' ' . ]
|
|
|
|
: .top [ print nl ]
|
|
|
|
: .lookup [ lookup . nl ]
|
|
|
|
: max [ dup lrot dup lrot rot > ifelse [ drop ] [ rot drop ] ]
|
|
|
|
: min [ dup lrot dup lrot rot < ifelse [ drop ] [ rot drop ] ]
|
|
|
|
: 0< [ 0 < ]
|
|
|
|
: 0= [ 0 = ]
|
|
|
|
: >0 [ 0 > ]
|
|
|
|
: 1+ [ 1 + ]
|
|
|
|
: 1- [ 1 - ]
|
|
|
|
: 2* [ 2 * ]
|
|
|
|
|