Lasso Soft Inc. > Home

[ max ]

Method

The [max] method compares two values  and returns the larger of the two. 

While this method is most commonly used with numeric parameters it may be used to compare objects of other types such as strings or even compound types like pairs and arrays. In these cases the first character of the string, or the first character of the first element of a compound data type is used for comparison. 

  • Syntax
max( value_1, value_2 )
Examples
  • Beginner

To return the larger of  two numbers

Use the [max] method. This example iterates through an array of values and uses the [max] method to return the maximum value of the data set.

Code

var( temperatures = array(27, 25, 30, 22, 31, 28, 27),
     maxTemp = integer )

with t in $temperatures 
     do => {
          $maxTemp = max($maxTemp, #t)
     }

'The maximum temperature was '+$maxTemp+' degrees.'

Result

The maximum temperature was 31 degrees.

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft