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

m
No edit summary
Line 653:
<syntaxhighlight lang="futurebasic">include "NSLog.incl"
 
void local fn StringGetVowelAndConsonentCountStringGetVowelAndConsonantCount( string as CFStringRef, vowels as ^long, consonents as ^long )
CFCharacterSetRef vowelSet = fn CharacterSetWithCharactersInString( @"aeiou" )
CFMutableCharacterSetRef consonentSetconsonantSet = fn MutableCharacterSetLetterSet
fn MutableCharacterSetRemoveCharactersInString( consonentSetconsonantSet, @"aeiou" )
*vowels = len( fn StringComponentsSeparatedByCharactersInSet( string, vowelSet ) ) - 1
*consonents = len( fn StringComponentsSeparatedByCharactersInSet( string, consonentSetconsonantSet ) ) - 1
end fn
 
void local fn DoIt
long index, vowels, consonentsconsonants
CFArrayRef strings = @[@"abcdefghijklmnop345qrstuvwxyz",
Line 669:
for index = 0 to len(strings) - 1
fn StringGetVowelAndConsonentCountStringGetVowelAndConsonantCount( strings[index], @vowels, @consonentsconsonants )
NSLog(@"\"%@\" contains %ld vowels and %ld consonentsconsonants",strings[index],vowels,consonentsconsonants)
next
end fn
Line 679:
{{out}}
<pre>
"abcdefghijklmnop345qrstuvwxyz" contains 5 vowels and 21 consonentsconsonants
"The quick brown fox jumps over the lazy dog" contains 11 vowels and 24 consonentsconsonants
"The answer my friend is blowing in the wind" contains 11 vowels and 24 consonentsconsonants
</pre>
 
 
 
=={{header|Go}}==
416

edits