Created
August 18, 2019 08:15
-
-
Save jasongorman/0aa747a45ce7e40f79f6ba4763e2d667 to your computer and use it in GitHub Desktop.
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
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