Fibonacci word/fractal: Difference between revisions

m
J
(Let's not exceed current display size by too many orders of magnitude?)
m (J)
Line 336:
return p1
end</lang>
 
=={{header|J}}==
 
Plotting the fractal as a parametric equation, this looks reasonably nice:
 
<lang J>plot }:+/\ 0,*/\(^~ 0j_1 0j1 $~ #)'0'=_1{::F_Words 20</lang>
 
However, image uploads are currently disabled, and rendering images of this sort as wikitext gets bulky.
 
Instead, I'll just describe the algorithm:
 
This draws a discrete parametric curve. Right turn is 0j_1, left turn is 0j1 (negative and positive square roots of negative 1), straight ahead is 1. So: build a list of alternating 0j_1 and 0j1 and raise them to the first power for the 0s in the fibonacci word list and raise them to the 0th power for the 1s in that list. Then compute the running product, shift a 0 onto the front of the list and compute the running sum. (Of course, this would translate to a rather simple loop, also, once you see the pattern.)
 
=={{header|Logo}}==
6,962

edits