Update lindenmayer to not use lists
parent
4ba810d7f7
commit
f5e5777b8d
|
@ -1,5 +1,5 @@
|
||||||
USING: kernel alien namespaces arrays vectors math opengl math-contrib
|
USING: kernel alien namespaces arrays vectors math opengl math-contrib
|
||||||
lists parser sequences hashtables strings ;
|
parser sequences hashtables strings ;
|
||||||
|
|
||||||
IN: lindenmayer
|
IN: lindenmayer
|
||||||
|
|
||||||
|
@ -127,13 +127,13 @@ SYMBOL: rules
|
||||||
|
|
||||||
: segment ( str -- seq )
|
: segment ( str -- seq )
|
||||||
{ { [ dup "" = ] [ drop [ ] ] }
|
{ { [ dup "" = ] [ drop [ ] ] }
|
||||||
{ [ dup length* 1 = ] [ f cons ] }
|
{ [ dup length* 1 = ] [ unit ] }
|
||||||
{ [ dup 1 swap nth CHAR: ( = ]
|
{ [ 1 over nth CHAR: ( = ]
|
||||||
[ dup CHAR: ) swap index 1 +
|
[ CHAR: ) over index 1 + ! str i
|
||||||
2dup head ! str i head
|
2dup head ! str i head
|
||||||
-rot tail ! head tail
|
-rot tail ! head tail
|
||||||
segment cons ] }
|
segment swap add* ] }
|
||||||
{ [ t ] [ dup 1 head swap 1 tail segment cons ] } }
|
{ [ t ] [ dup 1 head swap 1 tail segment swap add* ] } }
|
||||||
cond ;
|
cond ;
|
||||||
|
|
||||||
: lookup ( str -- str ) dup 1 head rules get hash dup [ nip ] [ drop ] if ;
|
: lookup ( str -- str ) dup 1 head rules get hash dup [ nip ] [ drop ] if ;
|
||||||
|
|
Loading…
Reference in New Issue