45 lines
1.4 KiB
Plaintext
45 lines
1.4 KiB
Plaintext
include "NSLog.incl"
|
|
|
|
local fn IsPangram( pangramString as CFStringRef ) as BOOL
|
|
NSUInteger i, count
|
|
BOOL result
|
|
|
|
CFStringRef lcPanStr = fn StringLowerCaseString( pangramString )
|
|
CFMutableSetRef mutSet = fn MutableSetWithCapacity( 0 )
|
|
|
|
count = len(lcPanStr)
|
|
for i = 0 to count - 1
|
|
if ( fn CharacterSetCharacterIsMember( fn CharacterSetLowercaseLetterSet, fn StringCharacterAtIndex( lcPanStr, i ) ) )
|
|
MutableSetAddObject( mutSet, fn StringWithFormat( @"%c", fn StringCharacterAtIndex( lcPanStr, i ) ) )
|
|
end if
|
|
next
|
|
if fn SetCount( mutSet ) >= 26 then result = YES else result = NO
|
|
end fn = result
|
|
|
|
|
|
CFStringRef testStr, trueStr, falseStr
|
|
CFArrayRef array
|
|
|
|
trueStr = @"Is a pangram"
|
|
falseStr = @"Not a pangram"
|
|
|
|
array = @[¬
|
|
@"My dog has fleas.",¬
|
|
@"The quick brown fox jumps over the lazy do.",¬
|
|
@"The quick brown fox jumped over the lazy dog.",¬
|
|
@"The quick brown fox jumps over the lazy dog.",¬
|
|
@"Jackdaws love my big sphinx of quartz.",¬
|
|
@"What's a jackdaw?",¬
|
|
@"Watch \"Jeopardy!\", Alex Trebek's fun TV quiz game.",¬
|
|
@"Pack my box with five dozen liquor jugs.",¬
|
|
@"This definitely is not a pangram.",¬
|
|
@"This is a random long sentence just for testing purposes."]
|
|
|
|
for testStr in array
|
|
if ( fn IsPangram( testStr ) )
|
|
NSLog( @"%13s : %@", fn StringUTF8String( trueStr ), testStr ) else NSLog( @"%s : %@", fn StringUTF8String( falseStr ), testStr )
|
|
end if
|
|
next
|
|
|
|
HandleEvents
|