* Guile code for L-system
@ 2006-05-24 13:02 Giancarlo Bassi
2006-05-24 13:16 ` Dave Griffiths
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Giancarlo Bassi @ 2006-05-24 13:02 UTC (permalink / raw)
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
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Guile code for L-system
2006-05-24 13:02 Guile code for L-system Giancarlo Bassi
@ 2006-05-24 13:16 ` Dave Griffiths
2006-05-24 18:28 ` Neil Jerram
2006-06-01 3:37 ` Scott W. Dunlop
2 siblings, 0 replies; 4+ messages in thread
From: Dave Griffiths @ 2006-05-24 13:16 UTC (permalink / raw)
Cc: Guile Mailing list
> 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.
I don't know if you are asking, but I have some code to do this (with
strings rather than lists though) here:
http://cvs.savannah.gnu.org/viewcvs/livenoisetools/livenoisetools/pattern-cascade/lsys.scm?view=markup
I've been using it to generate music for live performaces. FWIW I've
written this code in C++, python and now scheme, which has turned out to
be a lot more elegant, as usual :)
cheers,
dave
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Guile code for L-system
2006-05-24 13:02 Guile code for L-system Giancarlo Bassi
2006-05-24 13:16 ` Dave Griffiths
@ 2006-05-24 18:28 ` Neil Jerram
2006-06-01 3:37 ` Scott W. Dunlop
2 siblings, 0 replies; 4+ messages in thread
From: Neil Jerram @ 2006-05-24 18:28 UTC (permalink / raw)
Cc: Guile Mailing list
Giancarlo Bassi <g.bassi@iperbole.bologna.it> writes:
> 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)
(define (iterate l)
(apply append
(map (lambda (x)
(case x
((a) '(b))
((b) '(a b))))
l)))
>
> 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.
I'm afraid you've lost me here.
Neil
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Guile code for L-system
2006-05-24 13:02 Guile code for L-system Giancarlo Bassi
2006-05-24 13:16 ` Dave Griffiths
2006-05-24 18:28 ` Neil Jerram
@ 2006-06-01 3:37 ` Scott W. Dunlop
2 siblings, 0 replies; 4+ messages in thread
From: Scott W. Dunlop @ 2006-06-01 3:37 UTC (permalink / raw)
Cc: Guile Mailing list
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
> Guile-user@gnu.org
> http://lists.gnu.org/mailman/listinfo/guile-user
_______________________________________________
Guile-user mailing list
Guile-user@gnu.org
http://lists.gnu.org/mailman/listinfo/guile-user
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-06-01 3:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-24 13:02 Guile code for L-system Giancarlo Bassi
2006-05-24 13:16 ` Dave Griffiths
2006-05-24 18:28 ` Neil Jerram
2006-06-01 3:37 ` Scott W. Dunlop
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).