Last active
December 22, 2015 06:18
-
-
Save acook/6429623 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(i, 0, 100, | |
fizzed_or_buzzed := false; | |
if(i % 5 == 0, "Fizz" print; fizzed_or_buzzed := true); | |
if(i % 3 == 0, "Buzz" print; fizzed_or_buzzed := true); | |
if(fizzed_or_buzzed, "", i) println | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for(i, 0, 100, if(i % 3 == 0, if(i % 5 == 0, "FizzBuzz", "Buzz"), if(i % 5 == 0, "Fizz", i)) println) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FizzBuzz := Object clone | |
FizzBuzz run := method(min, max, for(number, min, max, (n := FizzBuzz Number clone; n value = number; n text println))) | |
FizzBuzz Number := Object clone | |
FizzBuzz Number value ::= nil | |
FizzBuzz Number three := method(value % 3 == 0) | |
FizzBuzz Number five := method(value % 5 == 0) | |
FizzBuzz Number text := method(if(three, if(five, "FizzBuzz", "Buzz"), if(five, "Fizz", value))) | |
FizzBuzz run(0, 100) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment