Gosper-curve from 'co routine

2017-03-05 Thread Lindsay John Lawrence
Using Picolisp 'co routine to...

Generate Gosper-curve states from L-System rules

: (GosperGen T)  # Reset
-> T
: (do 64 (prin (GosperGen)))
A-B--B+A++AA+B--+A-BB--B-A++A+B--+A-BB--B-A++A+B+A-B--B+A++AA+B--> "-"
: (GosperGen)
-> "+"
: (GosperGen)
-> "+"
: (GosperGen)
-> "A"
..

A depth of 12 generates about 32GB worth of information...

This uses very little stack and is easily generalized for other L-Systems
to generate rules for 'growing'  complex images that can be rendered using
the picolisp canvas drawing lib.

/Lindsay


# A and B mean to move forward
# + means to turn left 60 degrees
# - means to turn right 60 degrees

(de GosperGen (D)
   (if (=T D)
  (co 'gospergen)
  (co 'gospergen
 (let
(A (chop "A-B--B+A++AA+B-")
   B (chop "+A-BB--B-A++A+B")
   _MaxDepth D
   _Plot '((L) (mapc yield L))
   _Fn
   '((X)
  (cond
 ((= X "A") A)
 ((= X "B") B)
 (T (list X)) ) )
   _L-Run
   '((L D)
  (if (>= D _MaxDepth)
 (_Plot L)
 (mapc
'((X) (_L-Run (_Fn X) (inc D)))
L ) ) ) )
(default _MaxDepth 13)
(_L-Run A 1) ) ) ) )


Re: TC -> Loop Transformation?

2017-03-05 Thread Alexander Burger
Hi Christopher,

thanks for sharing these ideas!

However I'm a bit clueless about what you want to achieve.

> Hi, I while ago I asked how I might somehow represent a loop as a a tail
> call recursion, so as to give me the pattern I like without the call
> penalties.

Isn't it a lot easier to write a 'while', 'for' or 'do' loop then?

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: French localization

2017-03-05 Thread Alexander Burger
Hi all,

thanks to Raman and Eric the french localization is now included in the newest
release :)

It can also be tested on the demo app.7fach.de

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Namespace Chaining

2017-03-05 Thread Alexander Burger
Hi all,

with the newest release (17.3.4) in software-lab.de/picoLisp.tgz, namespace
handling in Pil64 has changed a little.

Until now, there was always always a single active namespace, which was created
with the 'symbols' function, and contained a full copy of the argument
namespaces.

This made the internal symbols lookup (i.e. the read and print functions) simple
and fast. The drawback was a relatively large memory footprint (about 25 KiB per
namespace), and no satisfactory control over namespace-local symbols.


In the new version, we have not a single namespace, but a list of separate
namespaces, specifying a clear search order. New namespaces are empty, and grow
only as big as necessary. When printing a symbol, the namespace prefix can be
printed as it is now known in which namespace the symbol resides.


The programming interface did not change very much.

'symbols' now returns a list of namespaces for the current search order.

The only significant change is 'local', which used to be called with symbolic
arguments as

   (local abc def ghi)  # Old version

but now needs to be called in a bit unusual way: It takes no "normal" arguments,
but 'read's a list of symbols from the current input channel. In praxis, this
means the list of symbols is directly written after (local):

   (local) [abc def ghi]

or

   (local)
   [abc def ghi jkl]

or

   (local) [
  abc def ghi
  jkl mno pqr
   ]

or similar. I'm using super parentheses here to make it visually clear, but of
cours normal ( .. ) parentheses can be used as well.

This access of the symbols in this list is done by 'local' only in the first
namespace of the current search order, causing these symbols to be found or
created in that namespace, giving truly local symbols.


A typical source file would have a 'symbols' and a 'local' call in the beginning
(and perhaps more 'local' calls later)

   (symbols 'lib1 'pico)
   (local) [foo bar]

   (de foo () ..
   (de bar () ..

while another might be

   (symbols 'lib2 'lib1 'pico)
   (local) [mumble]

   (de mumble ()
  (foo ..) )

Many other combinations are possible, e.g.

   (symbols 'lib2 'pico)
   (local) [mumble]

   (de mumble ()
  (lib1~foo ..) )


Symbols from other namespaces can be overshadowed

   (symbols 'lib1 'pico)
   (local) [put get]

   (de put ()
  ..
  (pico~put ..)  # Call the built-in 'put'
  ..

   (de get ()
  ..
  (pico~get ..)
  ..

♪♫ Alex
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe