Last active
November 25, 2016 14:36
-
-
Save sliskiCode/9d2ac4fcee5d1a43d028a009eaa835c1 to your computer and use it in GitHub Desktop.
7 things you probably don’t know about Kotlin #9
This file contains hidden or 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
| val prices = listOf(21.8, 232.5, 231.3) | |
| val taxedDiscountedRounded = compose(::taxed, ::discounted, ::rounded) | |
| prices.map(taxedDiscountedRounded) | |
| fun <A, B> compose(f: (A) -> A, | |
| g: (A) -> A, | |
| h: (A) -> B): (A) -> B = { x -> h(g(f(x))) } | |
| fun taxed(value: Double): Double = value * 1.4 | |
| fun discounted(value: Double): Double = value * 0.9 | |
| fun rounded(value: Double): Double = Math.round(value).toDouble() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment