Lasso Soft Inc. > Home

[ range ]

Method

The [range] method tests a value to see if it exists within a given range. The method takes three parameters, the value to be tested and the minimum and maximum values of the test range. [range] will always return one of the three parameters it receives. 

range(val, min, max) returns:

  • val when min < val < max
  • min when val < min
  • max when val > max
  • Syntax
range( test_val, minimum, maximum )
Examples
  • Beginner

To ensure that values lie within a specified range

Use the [range] method. This example normalises a set of data to fit within the specified range.

Code

var( myValues = array(22, 30, 17, 5, 16, 25, 21, 24),
     constrainedValues = array )

with v in $myValues
     do => {
          $constrainedValues->insert( range( #v, 16, 24 ) )
     }

$constrainedValues

Result

array(22, 24, 17, 16, 16, 24, 21, 24)

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