RosettaCodeData/Task/Thue-Morse/Factor/thue-morse.factor
2023-07-01 13:44:08 -04:00

8 lines
240 B
Factor

USING: io kernel math math.parser sequences ;
: thue-morse ( seq n -- seq' )
[ [ ] [ [ 1 bitxor ] map ] bi append ] times ;
: print-tm ( seq -- ) [ number>string ] map "" join print ;
7 <iota> [ { 0 } swap thue-morse print-tm ] each