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 / comma-quibbling.wiki

75 lines · 1335 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"
7text lb "{"
8text rb "}"
9text sep ", "
10text tand " and "
11text w1 "ABC"
12text w2 "ABC DEF"
13text w3 "ABC DEF G H"
14note emit writes every byte of a to stdout; a short write is retried, an error exits 1
15fn emit a view uchar * to void
16o = ulong 0
17while lt o len a bound 4096
18k = write 1 a o sub len a o
19if le k 0
20exit 1
21end
22o = add o ulong k
23end
24end
25note quib takes the words of a (single spaces between them): all but the last two are followed by a
26note comma, the last two are joined by "and", inside braces
27fn quib a view uchar * to void
28st = new ulong 16 0
29ln = new ulong 16 0
30k = ulong 0
31s = ulong 0
32for i ulong add len a 1
33e = eq i len a
34if not e
35e = eq get a i 32
36end
37if and e gt i s
38put st k s
39put ln k sub i s
40k = add k 1
41end
42if e
43s = add i 1
44end
45end
46emit lb
47for w ulong k
48if gt w 0
49if eq w sub k 1
50emit tand
51else
52emit sep
53end
54end
55emit part a get st w get ln w
56end
57emit rb
58emit nl
59end
60fn main to int
61note the empty list, as a slice of length 0
62quib part w1 0 0
63quib w1
64quib w2
65quib w3
66ret 0
67end
68</syntaxhighlight>
69{{out}}
70<pre>
71{}
72{ABC}
73{ABC and DEF}
74{ABC, DEF, G and H}
75</pre>