
The Fibonacci word may be represented as a fractal as described here:


(Clicking on the above website   (hal.archives-ouvertes.fr)    will leave a cookie.)



For F_wordm start with F_wordCharn=1
Draw a segment forward
If current F_wordChar is 0
Turn left if n is even
Turn right if n is odd
next n and iterate until end of F_word


Task

Create and display a fractal similar to Fig 1.


(Clicking on the above website   (hal.archives-ouvertes.fr)    will leave a cookie.)

#lang racket
(require "Fibonacci-word.rkt")
(require graphics/value-turtles)
 
(define word-order 23) ; is a 3k+2 fractal, shaped like an n
(define height 420)
(define width 600)
 
(define the-word
  (parameterize ((f-word-max-length #f))
    (F-Word word-order)))
 
(for/fold ((T (turtles width height
                       0 height ; in BL corner
                       (/ pi -2)))) ; point north
  ((i (in-naturals))
   (j (in-string (f-word-str the-word))))
  (match* (i j)
    ((_ #\1) (draw 1 T))
    (((? even?) #\0) (turn -90 (draw 1 T)))
    ((_ #\0) (turn 90 (draw 1 T)))))