Apply a callback to an array: Difference between revisions

no edit summary
No edit summary
Line 333:
{square * . [id, id]}
& square: <1,2,3,4,5>
 
== [[Groovy]] ==
[[Category:Groovy]]
 
Print each value in a list
[1,2,3,4].each { println it }
 
Create a new list containing the squares of another list
[1,2,3,4].collect { it * it }
 
== [[Haskell]] ==