Hi
I am trying to retrieve the highest number within a array.
lets say the array has stored 1 6 5 7 8 5 4 1 0 then i want the number 8.
Who has the answer?
Thanx!
Kind Regards.
Savvy001
use local var = 0
loop through the values in the array
if array value > local var set local var = array value
local var will have highest value from array
Develop games in your browser. Powerful, performant & highly capable.
ninja'd but here we go:
global number highest=0 +----------------------+ | | set highest to array.at(0) +----------------------+ +-------------------+ | array: for each x | set highest to max(highest, array.curValue) +-------------------+ [/code:2it05qpz]
ninja'd but here we go: global number highest=0 +----------------------+ | | set highest to array.at(0) +----------------------+ +-------------------+ | array: for each x | set highest to max(highest, array.curValue) +-------------------+ [/code:2svqpcd9]
global number highest=0 +----------------------+ | | set highest to array.at(0) +----------------------+ +-------------------+ | array: for each x | set highest to max(highest, array.curValue) +-------------------+ [/code:2svqpcd9]
fancy
I'm always fumbling with the build in array options :\ and tend to use:
var = 0
for 0 to array.width
(compare 2 values) array.at(loopindex) > var set var array.at(loopindex)
Thanks Guys!!
That helped me out.
I Ninja'd the highest number
Should be:
for 0 to array.width-1
Should be: for 0 to array.width-1
Redundant ... it would not have been > 0 anyways
In this case, but as a general pattern, width-1 is correct.
blackhornet is correct when he says general pattern, width-1 is correct.