Looping
If you’ve been programming for very long, you might’ve heard of the “fizzbuzz” problem. It was once a common interview question that was asked to see whether candidates could write a simple program, and it’s still used these days as a common example when teaching new programmers. There are a few minor variations of the problem, but let’s consider this version of it:
Given a number, fizzBuzzCount, return a string that contains all of the numbers from one, up to and including fizzBuzzCount, except:
-
If the number is evenly divisible by 3, but not evenly divisible by 5, replace it with the word “fizz”.
-
If the number is evenly divisible by 5, but not evenly divisible by 3, replace it with the word “buzz”.
-
If the number is evenly divisible ...
Get Effective Haskell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.