Lasso Soft Inc. > Home

[ min ]

Method

The [min] method compares two values and returns the smaller 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
min( value_1, value_2 )
Examples
  • Beginner

To return the smaller of two numbers

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

Code

var( temperatures = array(27, 25, 30, 22, 31, 28, 27),
     minTemp = $temperatures->get(1) )

with t in $temperatures 
     do => {
          $minTemp = min($minTemp, #t)
     }

'The minimum temperature was '+$minTemp+' degrees.'

Result

The minimum temperature was 22 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 2014 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft