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


 
 
{def thue_morse
 {def thue_morse.r
  {lambda {:steps :s1 :s2 :i}
   {if {> :i :steps}
    then :s1
    else {thue_morse.r :steps :s1:s2 :s2:s1 {+ :i 1}}}}}
 {lambda {:steps}
  {thue_morse.r :steps 0 1 1}}}
-> thue_morse
 
{thue_morse 6}
-> 0110100110010110100101100110100110010110011010010110100110010110
 
 