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