Skip to content

Instantly share code, notes, and snippets.

@jasongorman
Created August 18, 2019 08:11
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 jasongorman/8c8ad039efca2b3bd91b9d7ef7d78e6a to your computer and use it in GitHub Desktop.
Save jasongorman/8c8ad039efca2b3bd91b9d7ef7d78e6a to your computer and use it in GitHub Desktop.
fun quote(pricePerSqrMtr: Double, roundUp: Boolean, area: () -> Double): Double {
return carpetPrice(pricePerSqrMtr, roundUp, area())()
}
fun carpetPrice(pricePerSqrMtr: Double, roundUp: Boolean, area: Double): ()->Double {
fun price(): Double {
val areaToPrice = if (roundUp) {
Math.ceil(area)
} else {
area
}
return pricePerSqrMtr * areaToPrice
}
return ::price
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment