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.




import extensions;
 
extension op
{
    get Maximal()
    {
        auto en := cast Enumerator(self.enumerator());
 
        object maximal := nil;
        while (en.next())
        {
            var item := en.get();
            if (nil == maximal)
            {
                maximal := item
            } 
            else if (maximal < item)
            {
                maximal := item
            }
        };
 
        ^ maximal   
    }
}
 
public program()
{
    console.printLine(new int[]{1,2,3,4,20,10,9,8}.Maximal)
}