Hi Alex, Joh-Tob,

A 'co may be exactly what I am looking for in this case.  Thanks!

Generating all the states at once was nice in one sense as I could
immediately scale the view when rendering the results.
Picolisp easily supported lists of ~2M elements on the  4GB, single-core
virtual box I am currently using.

The code below is the recursive Gosper implementation I came up with that
uses very little stack. This version just emits states.
It should be easy to adapt to other L-systems, but doesn't yet have the
state management needed to 'grow' fractal plants.

If you want to "space-fill" (
https://en.wikipedia.org/wiki/Space-filling_curve) your hard drive with a
Gosper, or similar, curve...
This will do it for you ;)

: (out "test.dat" (nil (GosperR 10)))
: (call 'ls "-l")
-rw-r--r-- 1 llawrence llawrence 659108913 Mar  3 14:58 test.dat

Just counting the state changes emitted...

: (bench (nil (GosperR 10)) (msg (text "EmitCount: @1" EmitCount)))
"EmitCount: 659108913"
50.547 sec

: (bench (nil (GosperR 11)) (msg (text "EmitCount: @1" EmitCount)))
"EmitCount: 4613762399"
348.925 sec

Picolisp continues to impress me with its expressiveness and power.

/Lindsay

# ######################
# Recursive L-system emitter

(de Plot (L)
   (map '((X) (prin (car X))) L) )

(de Fn (L)
   (let R
      (fish
         atom
         (mapcar
            '((X)
               (cond
                  ((= X "A") A)
                  ((= X "B") B)
                  (T X) ) )
            L ) )
      R ) )

(de L-Run (L D)
   (cond
      ((>= D MaxDepth) (Plot L))
      (T
         (map
            '((X)
               (L-Run (Fn (list (car X))) (inc D)) )
            L ) ) ) )

(de GosperR (MaxDepth)
   (let (A (chop "A-B--B+A++AA+B-")
         B (chop "+A-BB--B-A++A+B"))
      (default MaxDepth 2)
      (L-Run A 1) ) )


On Fri, Mar 3, 2017 at 11:04 AM, Alexander Burger <a...@software-lab.de>
wrote:

> On Fri, Mar 03, 2017 at 01:39:25PM +0100, Joh-Tob Schäg wrote:
> > I haven't figured out how to do it yet, but I think, in this case, a
> > 'recursive' solution that renders as points are created would use a lot
> > less resources, assuming that processed replacement rules are garbage
> > collected as the stack unwinds and elements are traversed over.
> >
> > ​This sound like a case for 'co ​
>
> Makes sense probably.
>
> ♪♫ Alex
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>

Reply via email to