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/count-how-many-vowels-and-consonants-occur-in-a-string.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 / count-how-many-vowels-and-consonants-occur-in-a-string.wiki`
90 lines ยท 1638 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 tv "vowels "
8 text tc ", consonants "
9 text td "distinct vowels "
10 text msg "Now is the time for all good men to come to the aid of their country."
11 text vow "aeiou"
12 note emit writes every byte of a to stdout; a short write is retried, an error exits 1
13 fn emit a view uchar * to void
14 o = ulong 0
15 while lt o len a bound 4096
16 k = write 1 a o sub len a o
17 if le k 0
18 exit 1
19 end
20 o = add o ulong k
21 end
22 end
23 note emitu writes n in decimal; 20 digits hold every ulong
24 fn emitu n ulong to void
25 d = new uchar 20 0
26 i = ulong 20
27 v = n
28 while true bound 20
29 i = sub i 1
30 put d i uchar add rem v 10 48
31 v = div v 10
32 if eq v 0
33 break
34 end
35 end
36 emit part d i sub 20 i
37 end
38 note letters are ASCII a..z either case; vowels a e i o u, the other letters are consonants
39 fn main to int
40 seen = new uchar 26 0
41 v = ulong 0
42 c = ulong 0
43 for i ulong len msg
44 x = get msg i
45 if and ge x 65 le x 90
46 x = add x 32
47 end
48 if and ge x 97 le x 122
49 put seen sub x 97 1
50 isv = false
51 for j ulong len vow
52 if eq x get vow j
53 isv = true
54 end
55 end
56 if isv
57 v = add v 1
58 else
59 c = add c 1
60 end
61 end
62 end
63 emit tv
64 emitu v
65 emit tc
66 emitu c
67 emit nl
68 dv = ulong 0
69 dc = ulong 0
70 for j ulong 26
71 if eq get seen j 1
72 dc = add dc 1
73 end
74 end
75 for j ulong len vow
76 dv = add dv ulong get seen sub get vow j 97
77 end
78 emit td
79 emitu dv
80 emit tc
81 emitu sub dc dv
82 emit nl
83 ret 0
84 end
85
86 {{out}}
87
88 vowels 22, consonants 31
89 distinct vowels 5, consonants 13
90