1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- : true ( -- f ) -1 ;
- : false ( -- f ) 0 ;
- : div3? ( n -- f )
- dup 0=
- if
- true
- else
- dup 3 mod 0=
- then ;
- : div5? ( n -- f )
- dup 0=
- if
- true
- else
- dup 5 mod 0=
- then ;
- : fizz ( n -- n )
- div3?
- if ." fizz" then ;
- : buzz ( n -- n )
- div5?
- if ." buzz" then ;
- : fizzbuzz ( n -- )
- \ start with a -1 as counter
- -1
- \ 16 -1
- \ begin the loop
- begin
- \ increase counter, initially to 0
- 1+
- \ 16 0
- dup . fizz buzz cr
- \ duplicate for `<=`
- 2dup <=
- until
- 2drop ;
- 100 fizzbuzz .s
|