interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / drafts / rosettacode / thue-morse.wiki

51 lines · 1051 bytes Raw Blame History
1=={{header|Omegese}}==
2{{works with|omc|sha256 2c824805, aien-dev/omega-mv e5b32567, Linux AArch64}}
3Omega has no imports, so the small output helpers (<code>emit</code> and friends) are part of the program.
4<syntaxhighlight lang="text">
5om2
6text nl "\n"
7note emit writes every byte of a to stdout; a short write is retried, an error exits 1
8fn emit a view uchar * to void
9o = ulong 0
10while lt o len a bound 4096
11k = write 1 a o sub len a o
12if le k 0
13exit 1
14end
15o = add o ulong k
16end
17end
18note emitc writes the single byte c
19fn emitc c uchar to void
20b = new uchar 1 c
21emit b
22end
23note each step appends the bitwise complement of the sequence so far; 7 steps reach 64 terms
24fn main to int
25t = new uchar 64 0
26n = ulong 1
27for s ulong 7
28for i ulong n
29emitc add get t i uchar 48
30end
31emit nl
32if lt n 64
33for i ulong n
34put t add n i sub uchar 1 get t i
35end
36n = mul n 2
37end
38end
39ret 0
40end
41</syntaxhighlight>
42{{out}}
43<pre>
440
4501
460110
4701101001
480110100110010110
4901101001100101101001011001101001
500110100110010110100101100110100110010110011010010110100110010110
51</pre>