2012. január 18., szerda

Mandelbrot generator in Haskell

Whenever you learn a new language, you shall write a program that outputs "Hello World". It seems to be some kind of a law of the Universe. While such a useless piece of software fails to demonstrate almost any properties of the language itself, it's still a way to show how to compile and/or run programs on the platform in question.

There are a lot of classical problems that could be used to briefly scratch the surface of a new language. My favorite classical programming problem is drawing (an approximation of) the Mandelbrot set.

This exercise is versatile enough to shed some light on the language's philosophy and toolset, while being relatively simple.

Last time I stumbled upon Haskell, a really shiny gem among the languages I know. Guess what, I wrote a Mandelbrot set generator: https://github.com/netom/mandelbrot.hs.

I have to thank Daniel Pek (http://blog.pdani.org/) for telling me about his experiences with Haskell and infect me with the functional virus.