# to be run by your POSIX compliant SH interpreter of choice
#   Copyright (c) 1712-2024   by Olus

Thue_Morse_sequence='0'
while true; do
  next_segment=''
  for character in $(printf $Thue_Morse_sequence | sed -e 's/\(.\)/\1\n/g'); do
    if [ $character = '0' ]; then
      character='1'
    elif [ $character = '1' ]; then
      character='0'
    fi
    next_segment="$next_segment$character"
  done
  Thue_Morse_sequence="$Thue_Morse_sequence$next_segment"
done
