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

no edit summary
m (syntax highlighting fixup automation)
No edit summary
Line 649:
In string occur 23 consonants
</pre>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">include "NSLog.incl"
 
void local fn StringGetVowelAndConsonentCount( string as CFStringRef, vowels as ^long, consonents as ^long )
CFCharacterSetRef vowelSet = fn CharacterSetWithCharactersInString( @"aeiou" )
CFMutableCharacterSetRef consonentSet = fn MutableCharacterSetLetterSet
fn MutableCharacterSetRemoveCharactersInString( consonentSet, @"aeiou" )
*vowels = len( fn StringComponentsSeparatedByCharactersInSet( string, vowelSet ) ) - 1
*consonents = len( fn StringComponentsSeparatedByCharactersInSet( string, consonentSet ) ) - 1
end fn
 
void local fn DoIt
long index, vowels, consonents
CFArrayRef strings = @[@"abcdefghijklmnop345qrstuvwxyz",
@"The quick brown fox jumps over the lazy dog",
@"The answer my friend is blowing in the wind"]
for index = 0 to len(strings) - 1
fn StringGetVowelAndConsonentCount( strings[index], @vowels, @consonents )
NSLog(@"\"%@\" contains %ld vowels and %ld consonents",strings[index],vowels,consonents)
next
end fn
 
fn Doit
 
HandleEvents</syntaxhighlight>
{{out}}
<pre>
"abcdefghijklmnop345qrstuvwxyz" contains 5 vowels and 21 consonents
"The quick brown fox jumps over the lazy dog" contains 11 vowels and 24 consonents
"The answer my friend is blowing in the wind" contains 11 vowels and 24 consonents
</pre>
 
 
 
408

edits