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 / jewels-and-stones.wiki

69 lines · 1253 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 sp " "
8text s1 "aAAbbbb"
9text j1 "aA"
10text s2 "ZZ"
11text j2 "z"
12note emit writes every byte of a to stdout; a short write is retried, an error exits 1
13fn emit a view uchar * to void
14o = ulong 0
15while lt o len a bound 4096
16k = write 1 a o sub len a o
17if le k 0
18exit 1
19end
20o = add o ulong k
21end
22end
23note emitu writes n in decimal; 20 digits hold every ulong
24fn emitu n ulong to void
25d = new uchar 20 0
26i = ulong 20
27v = n
28while true bound 20
29i = sub i 1
30put d i uchar add rem v 10 48
31v = div v 10
32if eq v 0
33break
34end
35end
36emit part d i sub 20 i
37end
38note count the stones (bytes of s) that are jewels (occur in j); case matters
39fn jewels s view uchar * j view uchar * to ulong
40n = ulong 0
41for i ulong len s
42for k ulong len j
43if eq get s i get j k
44n = add n 1
45break
46end
47end
48end
49ret n
50end
51fn show s view uchar * j view uchar * to void
52emit s
53emit sp
54emit j
55emit sp
56emitu jewels s j
57emit nl
58end
59fn main to int
60show s1 j1
61show s2 j2
62ret 0
63end
64</syntaxhighlight>
65{{out}}
66<pre>
67aAAbbbb aA 3
68ZZ z 0
69</pre>