interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / si / rosetta / tasks / thue-morse / thue-morse.om

38 lines · 777 bytes Raw Blame History
1note Rosetta Code task "Thue-Morse": https://rosettacode.org/wiki/Thue-Morse
2note SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3om2
4text nl "\n"
5note emit writes every byte of a to stdout; a short write is retried, an error exits 1
6fn emit a view uchar * to void
7o = ulong 0
8while lt o len a bound 4096
9k = write 1 a o sub len a o
10if le k 0
11exit 1
12end
13o = add o ulong k
14end
15end
16note emitc writes the single byte c
17fn emitc c uchar to void
18b = new uchar 1 c
19emit b
20end
21note each step appends the bitwise complement of the sequence so far; 7 steps reach 64 terms
22fn main to int
23t = new uchar 64 0
24n = ulong 1
25for s ulong 7
26for i ulong n
27emitc add get t i uchar 48
28end
29emit nl
30if lt n 64
31for i ulong n
32put t add n i sub uchar 1 get t i
33end
34n = mul n 2
35end
36end
37ret 0
38end