Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Lindenmayer System in Clojure (nakkaya.com)
41 points by budu on Jan 26, 2010 | hide | past | favorite | 4 comments


The best thing about this program is that it shows the power of Clojure's Java interop. Doing graphics programming in other languages often feels like a dirty hack, but this isn't so bad. This might lead me back to try Clojure again

Aside: A few months ago I decided to reproduce a program a friend of mine wrote, which was to draw Koch's Snowflake without using recursion. By the end of the day, this morphed into a throwaway Lindenmayer system viewer in C++ with OpenGL. Basically it just lets you toggle the number of iterations and switch between 13 different fractals. The Clojure code is a lot nicer than the C++ that I banged out, which probably goes without saying! I was trying to add 20, but they were a pain to derive and I didn't want to work on it for more than a day

http://github.com/jakevoytko/fractals


Interesting; this article says the rewrite rule is F -> F+F-F-F+F , but Wikipedia says F → F−F++F−F . I think Wikipedia's is right, as (for a beginning) there are only four line segments in step N+1 for each line segment in step N. Take out the F between the minus signs in this article's rule, and it would be correct ( F -> F+F--F+F ), allowing for mirroring of the Wikipedia formula.


My mistake linked to the wrong page, formula I used is from L-System article, example 4.


Don't miss the graphics at the bottom.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: