Skip to content

Instantly share code, notes, and snippets.

@et4te
Created July 20, 2011 15:25
Show Gist options
  • Select an option

  • Save et4te/1095170 to your computer and use it in GitHub Desktop.

Select an option

Save et4te/1095170 to your computer and use it in GitHub Desktop.
: fizz? ( n -- ? )
3 mod 0 = ;
: buzz? ( n -- ? )
5 mod 0 = ;
: fizzbuzz? ( n -- ? )
[ fizz? ] [ buzz? ] bi and ;
: fizzbuzz-n ( n -- )
{ { [ dup fizzbuzz? ] [ drop "FizzBuzz" print ] }
{ [ dup fizz? ] [ drop "Fizz" print ] }
{ [ dup buzz? ] [ drop "Buzz" print ] }
{ [ t ] [ number>string print ] } } cond ;
: fizzbuzz ( -- )
100 [1,b] [ fizzbuzz-n ] each ;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment