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.




 
1) using the builtin primitive 
 
{max 556 1 7344 4 7 52 22 55 88 122 55 99 1222 578}
-> 7344
 
2) buidling a function
 
{def my-max
 {def max-h
  {lambda {:l :greatest}
   {if {A.empty? :l}
    then :greatest
    else {max-h {A.rest :l} 
                {if {> {A.first :l} :greatest}
                 then {A.first :l}
                 else :greatest}}}}}
 {lambda {:l}
  {if {A.empty? :l} then empty else {max-h :l {A.first :l}}}}}
-> my-max
 
{my-max {A.new 556 1 7344 4 7 52 22 55 88 122 55 99 1222 578}}
-> 7344
 