Forum breadcrumbs - You are here:WeLoveGod RallysPublic Forums: futurebasicRe: Getting the Max number from a …
You need to log in to create posts and topics.
Re: Getting the Max number from a set of numbers
77,940 Posts
#1 · April 5, 2022, 9:43 am
Quote from Forum Archives on April 5, 2022, 9:43 amPosted by: paboyle1703 <paboyle1703@...>
This is an adaptation of code from the Example folder, clunky but works, I'm sure there'll be more elegant solutions forthcoming
include "NSLog.incl"local fn MyComparator( os as OrderedSetRef, obj1 as CFTypeRef, obj2 as CFTypeRef ) as NSComparisonResult'~'1NSLog(@"%@,%@",obj1,obj2)NSComparisonResult result = fn StringCompare( obj1, obj2 )end fn = resultvoid local fn DoIt'~'1OrderedSetRef os = fn OrderedSetWithArray( @[@2,@44,@11,@99,@35] )NSLog(@"%@n",os)CFArrayRef array = fn OrderedSetSortedArrayUsingComparator( os, @fn MyComparator, NULL )NSUinteger count = fn ArrayCount(Array)NSLog(@"n%@ count= %d",array, count)NSLog(@"Max Number= %@", fn ArrayObjectAtIndex( array, count-1))end fnfn DoItHandleEvents
On Apr 4, 2022, at 22:07, Rich Love <[email protected]> wrote:
The following works in Objective-CBut how is this done in FutureBasic? (without using a C Function)NSArray *unsortedArray = @[ @2, @44, @11, @99, @35 ];NSNumber *maxNumber = [unsortedArray valueForKeyPath:@"@max.self"];NSLog(@"%@", maxNumber); // 99RichCarnation SoftwareMacWise Terminal emulation for Macintosh512 858-9234
--
To unsubscribe, send ANY message to: [email protected] To access the list archives, go to: http://freegroups.net/groups/futurebasic/
Peter BoyleFB 7.0.12OSX 10.14.6Xcode 10.2iMac 21.5 Late 20152.8 GHz Intel Core i5
--
To unsubscribe, send ANY message to: [email protected] To access the list archives, go to: http://freegroups.net/groups/futurebasic/
Posted by: paboyle1703 <paboyle1703@...>
This is an adaptation of code from the Example folder, clunky but works, I'm sure there'll be more elegant solutions forthcoming
include "NSLog.incl"
local fn MyComparator( os as OrderedSetRef, obj1 as CFTypeRef, obj2 as CFTypeRef ) as NSComparisonResult
'~'1
NSLog(@"%@,%@",obj1,obj2)
NSComparisonResult result = fn StringCompare( obj1, obj2 )
end fn = result
void local fn DoIt
'~'1
OrderedSetRef os = fn OrderedSetWithArray( @[@2,@44,@11,@99,@35] )
NSLog(@"%@n",os)
CFArrayRef array = fn OrderedSetSortedArrayUsingComparator( os, @fn MyComparator, NULL )
NSUinteger count = fn ArrayCount(Array)
NSLog(@"n%@ count= %d",array, count)
NSLog(@"Max Number= %@", fn ArrayObjectAtIndex( array, count-1))
end fn
fn DoIt
HandleEvents
On Apr 4, 2022, at 22:07, Rich Love <[email protected]> wrote:
The following works in Objective-CBut how is this done in FutureBasic? (without using a C Function)NSArray *unsortedArray = @[ @2, @44, @11, @99, @35 ];NSNumber *maxNumber = [unsortedArray valueForKeyPath:@"@max.self"];NSLog(@"%@", maxNumber); // 99RichCarnation SoftwareMacWise Terminal emulation for Macintosh512 858-9234
--
To unsubscribe, send ANY message to: [email protected] To access the list archives, go to: http://freegroups.net/groups/futurebasic/
Peter Boyle
FB 7.0.12
OSX 10.14.6
Xcode 10.2
iMac 21.5 Late 2015
2.8 GHz Intel Core i5
--
To unsubscribe, send ANY message to: [email protected] To access the list archives, go to: http://freegroups.net/groups/futurebasic/
Click for thumbs down.0Click for thumbs up.0