Skip to content

Instantly share code, notes, and snippets.

@jasongorman

jasongorman/quote.kt

Created Aug 18, 2019
Embed
What would you like to do?
fun quote(pricePerSqrMtr: Double, roundUp: Boolean, area: () -> Double): Double {
return carpetPrice(pricePerSqrMtr, roundUp, area())(area())
}
fun carpetPrice(pricePerSqrMtr: Double, roundUp: Boolean, area: Double): (Double)->Double {
fun price(area: Double): 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