Last active
August 29, 2015 14:05
-
-
Save fbiville/57648ba01f10b94e9a75 to your computer and use it in GitHub Desktop.
My second "real" Haskell program
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
foobarqix n = take n [ _substitute x | x <- [1..] ] | |
_substitute value = __substitute value "" [(3,"Foo"),(5,"Bar"),(7,"Qix")] | |
__substitute value "" [] = show value | |
__substitute value replacement [] = replacement | |
__substitute value replacement multiples = | |
let multiple = fst (head multiples) | |
string = snd (head multiples) | |
rest = tail multiples in | |
if (value `mod` multiple == 0) then | |
__substitute value (replacement ++ string) rest | |
else | |
__substitute value replacement rest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://www.haskell.org/haskellwiki/Haskell_Quiz/FizzBuzz