Groovy Functional Programming - Memoization
Suppose you have a computation heavy function.
def computeHeavyFunction(def number) {
println "computeHeavyFunction called with $number"
number + 1
}
println computeHeavyFunction(1)
println computeHeavyFunction(2)
println computeHeavyFunction(1)
In the absence of println statement, this function would have been pure. I have added the print statement just for the