Home > l-system

l-system

L-system is a project mainly written in Common Lisp, it's free.

L-system generator

This is an L-System expander (http://en.wikipedia.org/wiki/L-system) that takes a set of rules, a base state, and a number of iterations and will expand the base state.

For example using the "algae rules" from Wikipedia we can expand 8 iterations by calling:

(l-system:expander '("a" ((#a . "ab") (# . "a"))) 8)

outputs the following string:

"abaababaabaababaababaabaababaabaababaababaabaababaababa"

A more complete example using the "dragon curve" rules from wikipedia:

(l-system:expander '("fx" ((#x . "x+yf") (#y . "fx-y") (#f . "f") (#+ . "+") (#- . "-"))) 5)

outputs the following string:

"fx+yf+fx-yf+fx+yf-fx-yf+fx+yf+fx-yf-fx+yf-fx-yf+fx+yf+fx-yf+fx+yf-fx-yf-fx+yf+fx-yf-fx+yf-fx-yf"


A separate display portion of this project will use the turtle-graphics project (https://github.com/nowl/turtle-graphics) to attempt to display the string in an OpenGL context.

Previous:rails_tutorial