Monadic fractals

There are an awful lot of monad tutorials out there. Monads as containers is one I saw a link to on haskell-cafe today, and it gives a rather amazing application of the list monad:


f x | x == '#'  = "# #"
    | otherwise = "   "
"#" >>= f >>= f >>= f >>= f
= "# #   # #         # #   # #                           # #   # #         # #   # #"

And we have a fractal!

Leave a Reply