3 ms·
Feature request: Client should be able to specify either 3, or 1023 for the number needed to print "fizz." Feature request: Client should be able to optionall
by squeaky-clean 10y ago
Feature request: Client should be able to specify either 3, or 1023 for the number needed to print "fizz."
Feature request: Client should be able to optionally request "Lizard" as another string whenever the number is a multiple of 13.
That's what the article is referring to. Your function may be more clever, but it's more specific, works in only exactly the requested cases and is harder to change.
- mmierz 10y agofizzbuzz' :: Bool -> Bool -> Int -> String fizzbuzz' big doLiz n = (fizz . test 5 "buzz" . lizz) id (show n) where test d s x | n `mod` d == 0 = const (s ++ x "") | otherwise = x fizz = if big then (test 1023 "fizz") else (test 3 "fizz") lizz = if doLiz then (test 13 "Lizard") else id fizzbuzz :: Bool -> Bool -> [String] fizzbuzz big doLiz = map (fizzbuzz' big doLiz) [1..]
- tromp 10y agofizzbuzz' n = (test 1023 "fizz" . test 5 "buzz" . test 13 "Lizard") id (show n) easy as pie...