Skip to content

Instantly share code, notes, and snippets.

@guspower
Created November 25, 2013 11:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guspower/7640137 to your computer and use it in GitHub Desktop.
Save guspower/7640137 to your computer and use it in GitHub Desktop.
A few curried closures, groovy style
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