The   Fibonacci Word   may be created in a manner analogous to the   Fibonacci Sequence   as described here:

    Define   F_Word1   as   1
    Define   F_Word2   as   0
    Form     F_Word3   as   F_Word2     concatenated with   F_Word1    i.e.:   01
    Form     F_Wordn   as   F_Wordn-1   concatenated with   F_wordn-2



Task

Perform the above steps for     n = 37.

You may display the first few but not the larger values of   n.

{Doing so will get the task's author into trouble with them what be (again!).} 

Instead, create a table for   F_Words   1   to   37   which shows:

   The number of characters in the word
   The word's Entropy


Related tasks
 
   Fibonacci word/fractal
   Entropy
   Entropy/Narcissist


 
(lib 'struct)
(struct FW ( count0 count1 length string)) ;; a fibonacci word
(define (F-word n) ;; generator
    (define a (F-word (1- n)))
    (define b (F-word (- n 2)))
    (FW
        (+ (FW-count0 a) (FW-count0 b))
        (+ (FW-count1 a) (FW-count1 b))
        (+ (FW-length a) (FW-length b))
        (if (> n 9) "..." (string-append (FW-string a) (FW-string b)))))
 
(remember 'F-word (vector 0 (FW 0 1 1 "1") (FW 1 0  1 "0")))
 
(define (entropy fw)
    (define p (// (FW-count0 fw) (FW-length fw)))
    (cond
    ((= p 0) 0)
    ((= p 1) 0)
        (else (- 0 (* p (log2 p)) (* (- 1 p) (log2 (- 1 p)))))))
 
 
(define (task (n 38) (fw))
    (for ((i (in-range 1 n)))
        (set! fw (F-word i))
        (printf "%3d %10d %24d %a"
            i (FW-length fw) (entropy fw) (FW-string fw))))
 