Task

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.




 
'Works on any list with element types which support '>' comparisons
 
macro max any(R,  A, N,   i)
============================
  scope
    indexbase 1
    int i
    R=A(1)
    for i=2 to N
      if A(i)>R
        R=A(i)
      endif
    next
  end scope
end macro
 
'DEMO
=====
redim double d(100)
d={ 1.1, 1.2, 5.5, -0.1, -12.0 }
double m=max(d,5)
print "greatest element of d(): " m '5.5
 