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 / letter-frequency.wiki

88 lines · 1466 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 msg "The quick brown fox jumps over the lazy dog. Pack my box with five dozen liquor jugs! Sphinx of black quartz, judge my vow."
9note emit writes every byte of a to stdout; a short write is retried, an error exits 1
10fn emit a view uchar * to void
11o = ulong 0
12while lt o len a bound 4096
13k = write 1 a o sub len a o
14if le k 0
15exit 1
16end
17o = add o ulong k
18end
19end
20note emitu writes n in decimal; 20 digits hold every ulong
21fn emitu n ulong to void
22d = new uchar 20 0
23i = ulong 20
24v = n
25while true bound 20
26i = sub i 1
27put d i uchar add rem v 10 48
28v = div v 10
29if eq v 0
30break
31end
32end
33emit part d i sub 20 i
34end
35note emitc writes one byte
36fn emitc c uchar to void
37b = new uchar 1 0
38put b 0 c
39emit b
40end
41note counts the letters a..z, upper and lower case together, and prints every letter with its count
42fn main to int
43f = new ulong 26 0
44for i ulong len msg
45c = get msg i
46if and ge c 65 le c 90
47c = add c 32
48end
49if and ge c 97 le c 122
50put f sub c 97 add get f sub c 97 1
51end
52end
53for j ulong 26
54emitc add uchar j 97
55emit sp
56emitu get f j
57emit nl
58end
59ret 0
60end
61</syntaxhighlight>
62{{out}}
63<pre>
64a 4
65b 3
66c 3
67d 3
68e 6
69f 3
70g 3
71h 4
72i 5
73j 3
74k 3
75l 3
76m 3
77n 3
78o 9
79...
80s 3
81t 4
82u 6
83v 3
84w 3
85x 3
86y 3
87z 3
88</pre>