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

→‎{{header|Quackery}}: second interpretation of task
(Added Quackery.)
(→‎{{header|Quackery}}: second interpretation of task)
Line 1,065:
=={{header|Quackery}}==
 
<lang Quackery> [ bit
[ bit
[ 0 $ "AEIOUaeiuo"
witheach [ bit | ] ] constant
Line 1,093 ⟶ 1,092:
<pre>26 vowels
43 consonants
</pre>
 
'''OR''', depending on how you interpret the task…
 
<lang Quackery> [ 0 $ "AEIOU"
witheach [ bit | ] ] constant is vowels ( --> n )
 
[ 0 $ "BCDFGHJKLMNPQRSTVWXYZ"
witheach [ bit | ] ] constant is consonants ( --> n )
 
[ bit0 swap
[ dup 0 > while
tuck 1 & +
swap 1 >> again ]
drop ] is bitcount ( n --> n )
 
[ 0 swap witheach [ upper bit | ]
dup consonants & bitcount
swap vowels & bitcount ] is task ( $ --> n n )
 
$ "How fleeting are all human passions compared"
$ " with the massive continuity of ducks." join
task
echo say " distinct vowels" cr
echo say " distinct consonants"</lang>
 
{{out}}
 
<pre>5 distinct vowels
16 distinct consonants
</pre>
 
1,462

edits