Last active
January 1, 2023 11:01
-
-
Save NonCoderF/ff064d11b4e31c4743a0a33631f24837 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 main() { | |
val fun1: (Int) -> Int = { x -> x + 1 } | |
val fun2: (String) -> String = { x -> x.reversed() } | |
val fun3: (List<Int>) -> Int = { x -> x.sum() } | |
val fun4: (Double) -> Double = { x -> x * x } | |
val result1: (Int) -> Any = ::fun4::fun3::fun2::fun1 | |
val result2: (Int) -> Any = fun4::fun3::fun2::fun1 | |
val fun5: (Any) -> String = { x -> x.toString() } | |
val fun6: (String) -> String = { x -> x.capitalize() } | |
val fun7: (String) -> String = { x -> x.repeat(2) } | |
val fun8: (String) -> String = { x -> x.substring(1) } | |
val result3: (Int) -> String = fun8::fun7::fun6::fun5::result1 | |
val result4: (Int) -> String = ::fun8::fun7::fun6::fun5::result2 | |
println(result3(10)) // prints "100.0" | |
println(result4(10)) // prints "100.0" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It is not a good practice....Just for fun!