Created
June 30, 2020 04:25
-
-
Save humanscape-david/6ce357939d77c8d1184eaadf4334e1c4 to your computer and use it in GitHub Desktop.
코틀린에서 합성함수의 일반화
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
| fun main(args: Array<String>) { | |
| val addThree = { i: Int -> i + 3 } | |
| val twice = { i: Int -> i * 2 } | |
| val composedFunc = addThree compose twice | |
| println(composedFunc(3)) // 9 출력 | |
| } | |
| infix fun <F, G, R> ((F) -> R).compose(g: (G) -> F): (G) -> R { | |
| return { gInput: G -> this(g(gInput))} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment