How to resolve the algorithm Greatest element of a list step by step in the FutureBasic programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Greatest element of a list step by step in the FutureBasic programming language
Table of Contents
Problem Statement
Create a function that returns the maximum value in a provided set of values, where the number of values may not be known until run-time.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Greatest element of a list step by step in the FutureBasic programming language
Source code in the futurebasic programming language
include "NSLog.incl"
local fn GreatestElementInList( list as CFArrayRef ) as CFTypeRef
CfArrayRef array = fn ArraySortedArrayUsingSelector( list, @"compare:" )
CFTypeRef result = fn ArrayLastObject( array )
end fn = result
CFArrayRef array
array = @[@1, @-2, @10, @5.0, @10.5]
NSLog( @"%@", fn GreatestElementInList( array ) )
// Greatest element will be letter with highest ASCII value
array = @[@"A", @"b", @"C", @"d", @"E"]
NSLog( @"%@", fn GreatestElementInList( array ) )
array = @[@"ant", @"antelope", @"dog", @"cat", @"cow", @"wolf", @"wolverine", @"aardvark"]
NSLog( @"%@", fn GreatestElementInList( array ) )
array = @[@"abc", @"123", @"zyx", @"def"]
NSLog( @"%@", fn GreatestElementInList( array ) )
HandleEvents
You may also check:How to resolve the algorithm Even or odd step by step in the Lua programming language
You may also check:How to resolve the algorithm Increment a numerical string step by step in the Ring programming language
You may also check:How to resolve the algorithm Sieve of Eratosthenes step by step in the XPL0 programming language
You may also check:How to resolve the algorithm Mandelbrot set step by step in the Scala programming language
You may also check:How to resolve the algorithm Cyclops numbers step by step in the Ruby programming language