Lasso Soft Inc. > Home

[ median ]

Method

The [median] method accepts three parameters and returns the one whose value lies between the other two, essentially returning the median value of the 3 member set.

  • Syntax
median( value_1, value_2, value_3 )
Examples
  • Beginner

Return the median of a three number set

Use the [median] method. This example iterates through an array of arrays returning the median of each.

Code

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

with s in $mySets
     do => {^
          'The median of '+#s+' is '+median(#s->get(1), #s->get(2), #s->get(3))+'\n'     
     ^}

Result

The median of array(22, 30, 17) is 22
The median of array(5, 16, 25) is 16
The median of array(21, 21, 24) is 21

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