The [set->forEach] method allows an operation to be performed on each element of the set in turn.
set->forEach => {^ ^}
This example uses the [set->forEach] method to output a list of squares of each number in a set.
Code
define squareMe(n::integer=1) => {
return #n * #n
}
var( aSet = array(1, 2, 3, 5, 8, 13))
$aSet->forEach => {^ squareMe(#1)+' ' ^}
Result
1 4 9 25 64 169
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 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments