Created
November 25, 2013 11:45
-
-
Save guspower/7640137 to your computer and use it in GitHub Desktop.
A few curried closures, groovy style
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculatePrice = { float cost, float margin, float vat -> | |
(cost + margin) * (100 + vat)/100 | |
} | |
def standardRatePrice = calculatePrice.rcurry(20.0f) | |
def reducedRatePrice = calculatePrice.rcurry(5.0f) | |
def zeroRatePrice = calculatePrice.rcurry(0.0f) | |
void run() { | |
println standardRatePrice(10.0, 2.5) | |
println reducedRatePrice(10.0, 2.5) | |
println zeroRatePrice(10.0, 2.5) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment