Count how many vowels and consonants occur in a string: Difference between revisions

→‎{{header|Ring}}: simplified, removed unnecessary library dependency and chance of mis-tabulation of characters after "Z" and before "a"
(Added AutoHotkey)
(→‎{{header|Ring}}: simplified, removed unnecessary library dependency and chance of mis-tabulation of characters after "Z" and before "a")
Line 1,635:
 
=={{header|Ring}}==
<lang ring>? "working..."
load "stdlib.ring"
see "working..." + nl
str = '"' + "Forever Ring Programming Language" + '"'
vowel = 0 vowels = [] for x in "AEIOUaeiou" add(vowels, x) next
vowel = 0
ltrc = 0 all = 'A':'z' while all[27] != 'a' del(all, 27) end
cons =0
 
for n =in 1 to len(str)
if find(vowels, n) > 0 vowel++ ok
strc = str[n]
if isvowelfind(str[all, n]) => 0 ltrc++ 1ok
vowel += 1
ok
if isconsonant(strc)
cons += 1
ok
next
 
see? "Input string = " + str + nl
see? "In string occur " + vowel + " vowels" + nl
see? "In string occur " + cons(ltrc - vowel) + " consonants" + nl
seeput "done..." + nl</lang>
 
func isconsonant(c)
bool1 = not isvowel(c)
bool2 = (ascii(c) > 64 and ascii(c) < 91)
bool3 = (ascii(c) > 96 and ascii(c) < 123)
if bool1 and (bool2 or bool3)
return 1
else
return 0
ok
</lang>
{{out}}
<pre>working...
working...
Input string = "Forever Ring Programming Language"
In string occur 11 vowels
In string occur 19 consonants
done...</pre>
</pre>
 
=={{header|Ruby}}==