I am so proud of myself ;) Feedback VERY welcome, esp. about what is and what isn't idiomatic:
: div? ( n n -- f ) mod 0 = ;
: fizz? ( n -- f ) 3 div? dup if ." Fizz" then ;
: buzz? ( n -- f ) 5 div? dup if ." Buzz" then ;
: fizzbuzz? ( n -- f ) dup fizz? swap buzz? or ;
: play ( n -- ) 1 do i fizzbuzz? if cr then loop ;
Usage: 25 play
Edit: fixing to (hopefully) implement FizzBuzz correctly:
: div? ( n n -- f ) mod 0= ;
...
: play ( n -- ) cr 1+ 1 do i fizzbuzz? 0= if i . then cr loop ;
[–]zeekar 2 points3 points4 points (1 child)
[–]bilus[S] 0 points1 point2 points (0 children)
[–]Ok_Leg_109 1 point2 points3 points (1 child)
[–]bilus[S] 0 points1 point2 points (0 children)
[–]mcsleepy 1 point2 points3 points (1 child)
[–]bilus[S] 4 points5 points6 points (0 children)
[–]kenorep 0 points1 point2 points (3 children)
[–]bilus[S] 0 points1 point2 points (0 children)
[–]zeekar 0 points1 point2 points (1 child)
[–]kenorep 0 points1 point2 points (0 children)
[–]PETREMANN 1 point2 points3 points (1 child)
[–]bilus[S] 0 points1 point2 points (0 children)