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.




 
PROGRAM MAXLIST
 
!
! for rosettacode.org
!
 
! VAR L$,EL$,CH$,I%,MAX
 
BEGIN
  PRINT(CHR$(12);) ! CLS
  INPUT("Lista",L$)
  L$=L$+CHR$(32)
  MAX=-1.7E+38
  FOR I%=1 TO LEN(L$) DO
    CH$=MID$(L$,I%,1)
    IF CH$<>CHR$(32) THEN ! blank is separator
       EL$=EL$+CH$
     ELSE
       IF VAL(EL$)>MAX THEN MAX=VAL(EL$) END IF
       EL$=""
    END IF
  END FOR
  PRINT("Max list element is";MAX)
END PROGRAM
 