Dissecting the most difficult trivial programming puzzle
The FizzBuzz problem is said to be notoriously trivial, but it is not. Read the following (in the given order) to understand why:
-
FizzBuzz in Haskell by Embedding a Domain-Specific Language (fizzbuzz.pdf) - Originally published in the Monad.Reader magazine 💔. It describes why the problem is actually an instance of a difficult programming pattern that seems to require either code duplication, information-flow vs. control-flow mismatch, or higher-order functions. Of course, we choose the latter.
-
fizzbuzz.c - A C implementation of the solution proposed in the paper above. (Yes, if you look from the right angle, C is a dependently-typed functional language.)
-
fizzbuzz-semigroup.md - If your inner pedant is still not satisfied, let's ditch the empty list.
The solution from the Monad.Reader paper has been translated to many different languages by a number of programming languages enthusiasts. For example:
-
To Haskell by Mathias Verraes (the original implementation in the paper was actually in Haskell, but here the derivation is "animated" through file history)