Created
July 9, 2016 06:52
-
-
Save takasek/d13f87bbc8de7e218f6bf821d40438a7 to your computer and use it in GitHub Desktop.
りずさんのhttps://t.co/Yq0bfT8jdx をinfix operator使わず、普通の関数で書いてみた。結果は同じ。引数(タプルではない)にタプルを渡せる #CodePiece
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
| func apply <A, B>(f : A -> B, a : A) -> B { | |
| return f(a) | |
| } | |
| func p(a a: Int, b: Int) { | |
| print("a: \(a)") | |
| print("b: \(b)") | |
| } | |
| let tuple: (b: Int, a: Int) = (b: 2, a: 1) | |
| apply(p, a: tuple) | |
| //a: 1 | |
| //b: 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment