Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-rosetta/blob/main/tasks/thue-morse/thue-morse.om # omega-rosetta aien-dev/omega-rosetta Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-rosetta / tasks / thue-morse / thue-morse.om` 38 lines ยท 777 bytes Raw Blame History 1 note Rosetta Code task "Thue-Morse": https://rosettacode.org/wiki/Thue-Morse 2 note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 3 om2 4 text nl "\n" 5 note emit writes every byte of a to stdout; a short write is retried, an error exits 1 6 fn emit a view uchar * to void 7 o = ulong 0 8 while lt o len a bound 4096 9 k = write 1 a o sub len a o 10 if le k 0 11 exit 1 12 end 13 o = add o ulong k 14 end 15 end 16 note emitc writes the single byte c 17 fn emitc c uchar to void 18 b = new uchar 1 c 19 emit b 20 end 21 note each step appends the bitwise complement of the sequence so far; 7 steps reach 64 terms 22 fn main to int 23 t = new uchar 64 0 24 n = ulong 1 25 for s ulong 7 26 for i ulong n 27 emitc add get t i uchar 48 28 end 29 emit nl 30 if lt n 64 31 for i ulong n 32 put t add n i sub uchar 1 get t i 33 end 34 n = mul n 2 35 end 36 end 37 ret 0 38 end