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

no edit summary
(Add COBOL)
No edit summary
Line 461:
<pre>If not now, then when? If not us, then who?
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}}==