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

Content added Content deleted
(Added Quackery.)
(→‎{{header|Quackery}}: second interpretation of task)
Line 1,065: Line 1,065:
=={{header|Quackery}}==
=={{header|Quackery}}==


<lang Quackery>
<lang Quackery> [ bit
[ bit
[ 0 $ "AEIOUaeiuo"
[ 0 $ "AEIOUaeiuo"
witheach [ bit | ] ] constant
witheach [ bit | ] ] constant
Line 1,093: Line 1,092:
<pre>26 vowels
<pre>26 vowels
43 consonants
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 )

[ 0 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>
</pre>