Tuesday, 22 November 2011

Learning Clojure: Part 7

Victory!

Today I plotted my first Clojure Fractal.

It took a while. And I doubt that the quality of the code is anything to marvel at.

I have a complex number struct, three functions to perform basic operations on them (add, multiply & magnitude), two functions (one called from the other) to create a grid of complex numbers, one to create an iterator and three to piece it all together by passing all the entries in the grid to the iterator and printing the result line by line.

I'm pretty pleased with the result. Luckily I seem to have picked on an interesting fractal.
The formula is: z -> z2 + c
where c is 0.9 - 0.1i

Here's a better look at it after I tweaked some parameters:

No comments:

Post a Comment