Skip to content

Instantly share code, notes, and snippets.

@pgorzelany
Last active September 23, 2015 07:35
Show Gist options
  • Select an option

  • Save pgorzelany/08f086fd21f12036f86b to your computer and use it in GitHub Desktop.

Select an option

Save pgorzelany/08f086fd21f12036f86b to your computer and use it in GitHub Desktop.
Basic pipes implementation in Swift
/* Used for piping the results of consecutive functions
*/
infix operator |> { associativity left precedence 140 }
func |> <I, O>(input: I, transform: (I) -> O) -> O {
return transform(input)
}
let root = 4 + 3 * 4 |> {Double($0)} |> sqrt
print(root) // 4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment