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.




/**
 greatest element from a list (Neko Array)
 Tectonics:
   nekoc greatest-element.neko
   neko greatest-element
*/
 
var greatest = function(list) {
  var max, element;
  var pos = 1;
 
  if $asize(list) > 0  max = list[0];
 
  while pos < $asize(list) {
    element = list[pos];
    if max < element  max = element;
    pos += 1;
  }
 
  return max;
}
 
$print(greatest($array(5, 1, 3, 5)), "\n");
$print(greatest($array("abc", "123", "zyx", "def")), "\n");