Task

Create a Thue-Morse sequence.



See also
   YouTube entry: The Fairest Sharing Sequence Ever
   YouTube entry: Math and OCD - My story with the Thue-Morse sequence
   Task: Fairshare between two and more


thueMorse: function [maxSteps][
    result: new []
    val: [0]
    count: new 0
    while [true][
        'result ++ join to [:string] val
        inc 'count
        if count = maxSteps -> return result
        val: val ++ map val 'v -> 1 - v
    ]
    return result
]
loop thueMorse 6 'bits ->
    print bits