Created
August 9, 2012 07:41
-
-
Save repeatedly/3302048 to your computer and use it in GitHub Desktop.
FizzBuzz based on tanakh's Haskell
This file contains hidden or 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
import std.algorithm, std.conv, std.range, std.stdio; | |
// FizzBuzz from http://ideone.com/ciKtm | |
// I cannot port 'f <> b <|> n' | |
void main() | |
{ | |
auto fizz = cycle([null, null, "Fizz"]); | |
auto buzz = cycle([null, null, null, null, "Buzz"]); | |
auto nums = map!(to!string)(iota(1, 101)); | |
foreach (num; map!(e => (e[0] ~ e[1]).empty ? e[2] : e[0] ~ e[1])(zip(fizz, buzz, nums))) | |
writeln(num); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment