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