Count how many vowels and consonants occur in a string: Difference between revisions
Content added Content deleted
Not a robot (talk | contribs) (Add COBOL) |
No edit summary |
||
Line 461: | Line 461: | ||
<pre>If not now, then when? If not us, then who? |
<pre>If not now, then when? If not us, then who? |
||
10 vowels, 20 consonants.</pre> |
10 vowels, 20 consonants.</pre> |
||
=={{header|Common Lisp}}== |
|||
<lang lisp>(defun vowel-p (c &optional (vowels "aeiou")) |
|||
(and (characterp c) (characterp (find c vowels :test #'char-equal)))) |
|||
(defun count-vowels (s) |
|||
(and (stringp s) (count-if #'vowel-p s))) |
|||
(defun count-consonants (s) |
|||
(and (stringp s) (- (count-if #'alpha-char-p s) (count-vowels s))))</lang> |
|||
=={{header|Cowgol}}== |
=={{header|Cowgol}}== |