Skip to content

Instantly share code, notes, and snippets.

@rsp
Created November 29, 2017 14:15
Show Gist options
  • Save rsp/f78d80a70f46bbc0fbc57576807775e1 to your computer and use it in GitHub Desktop.
Save rsp/f78d80a70f46bbc0fbc57576807775e1 to your computer and use it in GitHub Desktop.
inFullMobile Language Wars: Round 1 - Swift Solution 1 - by @mikchmie-ifm - See: https://gist.github.com/rsp/d8bdbafa09f24f99eebc8ed60fe205c8
import Foundation
func f(_ foo: @escaping (@escaping (Int) -> Int) -> (Int) -> Int) -> (@escaping (Int) -> Int) -> (Int) -> Int {
return { op in
return { num in
let times = foo({ x in x + 1 })(0) - 1
return (0..<times).reduce(num, { result, _ in op(result) })
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment