interpret-string ( TURTLE STRING COMMANDS -- turtle )


Vocabulary
L-system

Inputs
TURTLEan object
STRINGan object
COMMANDSan object


Outputs
turtlean object


Definition


:: interpret-string ( TURTLE STRING COMMANDS -- turtle )
STRING empty? not [
[let
STRING read-instruction :> ( NEXT REST ) NEXT 1 head
COMMANDS at :> COMMAND COMMAND [
NEXT length 1 = [
TURTLE COMMAND ( turtle -- turtle ) call-effect
drop
] [
TURTLE NEXT 2 tail 1 head*
string>number COMMAND 1 tail*
( turtle x -- turtle ) call-effect drop
] if
] when TURTLE REST COMMANDS interpret-string drop ]
] when TURTLE ;