Skip to content

Instantly share code, notes, and snippets.

@darthpelo
Last active June 6, 2016 11:32
Show Gist options
  • Select an option

  • Save darthpelo/4f3ea6208d274f996de4a4c6577aaf40 to your computer and use it in GitHub Desktop.

Select an option

Save darthpelo/4f3ea6208d274f996de4a4c6577aaf40 to your computer and use it in GitHub Desktop.
Currying in Swift, an example
func appender(delimeter:String)->(String)->String {
var buffer = ""
return {
buffer += $0 + delimeter
return buffer
}
}
let strings = ["a", "b", "c"]
let append = appender(", ")
var res = ""
strings.forEach { res = append($0) }
print(res)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment