Count how many vowels and consonants occur in a string: Difference between revisions
Count how many vowels and consonants occur in a string (view source)
Revision as of 14:19, 18 September 2021
, 2 years ago→{{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 )
[ 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>
|