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

J
(Applesoft BASIC)
(J)
Line 856:
('t',1)
('v',1)</pre>
 
=={{header|J}}==
 
For this task, we restrict ourselves to english letters, and treat the semivowels (<code>w</code> and <code>y</code>) as consonants.
 
Implementation (two tallies: vowels first, consonants second):
 
<lang j>vowel=: (,toupper) 'aeiou'
consonant=: (,toupper) (a.{~97+i.16) -. vowel
vctally=: e.&vowel ,&(+/) e.&consonant</lang>
 
Examples:
 
<lang J> vctally 'Now is the time for all good men to come to the aid of their country.'
22 18
vctally 'Forever Action! programming language'
13 13</lang>
 
=={{header|JavaScript}}==
6,951

edits