Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,19 @@
|
|||
local fn FindLongest( test as CFArrayRef ) as CFStringRef
|
||||
'~'1
|
||||
CFStringRef s, t1 = @"", t2 = @""
|
||||
|
||||
for s in test
|
||||
if ( len(s) > len(t1) )
|
||||
t1 = s
|
||||
t2 = fn StringWithFormat( @"%@\n", s )
|
||||
else
|
||||
if ( len(s) == len(t1) )
|
||||
t2 = fn StringWithFormat( @"%@%@\n", t2, s )
|
||||
end if
|
||||
end if
|
||||
next
|
||||
end fn = t2
|
||||
|
||||
print fn FindLongest( @[@"a", @"bb", @"ccc", @"ddd", @"ee", @"f", @"ggg"] )
|
||||
|
||||
HandleEvents
|
||||
|
|
@ -0,0 +1,15 @@
|
|||
include "NSLog.incl"
|
||||
|
||||
_longestStringsToDisplay = 3
|
||||
|
||||
local fn LongestStrings( string as CFStringRef )
|
||||
CFArrayRef array = fn StringComponentsSeparatedByString( string, @" " )
|
||||
SortDescriptorRef sortAscending = fn SortDescriptorWithKey( @"length", YES )
|
||||
array = fn ArraySortedArrayUsingDescriptors( array, @[sortAscending] )
|
||||
array = fn ArraySubarrayWithRange( array, fn CFRangeMake( len(array)-_longestStringsToDisplay, _longestStringsToDisplay ) )
|
||||
NSLog( @"%@\n%@\n%@", array[0], array[1], array[2] )
|
||||
end fn
|
||||
|
||||
fn LongestStrings( @"a bb ccc ddd ee f ggg" )
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue