Count how many vowels and consonants occur in a string: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
No edit summary |
||
Line 649: | Line 649: | ||
In string occur 23 consonants |
In string occur 23 consonants |
||
</pre> |
</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> |
|||