Archive for August, 2012

I discovered an interesting trick today which I thought worth sharing – you can add a side effect to the end of a sequence in Clojure which will only get called after the sequence is fully consumed for the first time.

I’m pretty happy with the little fractal DSL which is implemented using keyword arguments. You can control pretty much every aspect of the iterative procedure used to create the fractal. There are some handy shortcuts you can use in your formulae:

x, y, z, t – the current co-ordinates in space that gets updated in each iteration

pos – the current co-ordinate vector

c – the initial co-orinate vector (i.e. equal to pos on the first iteration)

‘i – the iteration number. Note this is a symbol, I might make this into a function in the future for convenient to avoid the quote but you need it for now

For example, by tweaking the :result formula you can easily create some interesting fractal patterns:

Performance is also looking good – the image above took around 3secs to render on my machine. It’s amazing how much hardware has progressed – I still remember the days when I had to leave my Atari 800XL running overnight to get a low resolution mandelbrot image!

I see this question debated hotly in various forums, so I thought that it was worth addressing. Mostly in the name of dispelling some myths, but also to highlight what I feel are the most crucial foundations of functional programming.

And also because I think that definitions are important. They are central to both how we think and how we communicate.