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