Function malachite_base::iterators::thue_morse_sequence

source ·
pub const fn thue_morse_sequence() -> ThueMorseSequence 
Expand description

Returns an iterator that generates the Thue-Morse sequence.

The output length is infinite.

§Worst-case complexity per iteration

Constant time and additional memory.

§Examples

use malachite_base::iterators::thue_morse_sequence;

let s: String = thue_morse_sequence()
    .take(100)
    .map(|b| if b { '1' } else { '0' })
    .collect();
assert_eq!(
    s,
    "01101001100101101001011001101001100101100110100101101001100101101001011001101001011010011\
    00101100110"
)