Skip to content

Instantly share code, notes, and snippets.

@takasek
Created July 9, 2016 06:52
Show Gist options
  • Select an option

  • Save takasek/d13f87bbc8de7e218f6bf821d40438a7 to your computer and use it in GitHub Desktop.

Select an option

Save takasek/d13f87bbc8de7e218f6bf821d40438a7 to your computer and use it in GitHub Desktop.
りずさんのhttps://t.co/Yq0bfT8jdx をinfix operator使わず、普通の関数で書いてみた。結果は同じ。引数(タプルではない)にタプルを渡せる #CodePiece
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