Groovy Functional Programming - Function (Closure) Composition
Consider the following closures.
def increment = { number ->
number + 1
}
def square = { number ->
number * number
}
println increment(2) // 3
println square(2) // 4
If you are not familiar with closures, this article provides the necessary details.
Now suppose you want to calculate the square of a number