guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Guile code for L-system


From: Scott W. Dunlop
Subject: Re: Guile code for L-system
Date: Wed, 31 May 2006 23:37:09 -0400

The most succinct expansion implementation I could think of, in pure Scheme:

(define (expand-l-term term axioms)
  (let ((axiom (assq term axioms)))
    (if axiom
      (cdr axiom)
      (list term))))

(define (expand-l-expr expr axioms)
  (apply append (map (lambda (term)
                       (expand-l-term term axioms))
                     expr)))

>> (expand-l-expr '(b a b) '((a b) (b a b)))
:: (a b b a b)

--Scott.

On May 24, 2006, at 9:02 AM, Giancarlo Bassi wrote:

I want to write in Guile the code implementing these following rewriting rules, which are taken from L-system rewriting (from Lindenmayer's
"Algorithmic beauty of plants")

Axiom a
a -> b
b -> ab

So, it should be create these lists

`(a) `(b) `(a b) `(b a b) `(a b b a b)  `(b a b a b b a b)

You may notice that the lists' length are Fibonacci's number.

This drill should introduce my final purpose to write the
Guile code for the Hilbert-Peano's curve, which in L-system
looks as:

Axiom x
x -> - f y + x f x + f y -
y -> + x f - y f y - f x +

where f means a translation and + - are rotations.


Then I'll be able to write the drgeo script for actually drawing that
curve, which looks as limit for the number of iterations to infinity.

Thanks a lot.
                GB

---
"I'm no Pawn, I'm Donald Duck ! "
       -- Donald in MathMagic Land




_______________________________________________
Guile-user mailing list
address@hidden
http://lists.gnu.org/mailman/listinfo/guile-user





reply via email to

[Prev in Thread] Current Thread [Next in Thread]