Skip to content

Instantly share code, notes, and snippets.

@ayanonagon
Created June 4, 2014 01:30
Show Gist options
  • Select an option

  • Save ayanonagon/47916cff9b1e86f1c19c to your computer and use it in GitHub Desktop.

Select an option

Save ayanonagon/47916cff9b1e86f1c19c to your computer and use it in GitHub Desktop.

Revisions

  1. ayanonagon created this gist Jun 4, 2014.
    17 changes: 17 additions & 0 deletions FunctionApplication.playground
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    func fp<A, B, C>(fn:((A, B) -> C), arg:A) -> (B -> C) {
    func apply(b:B) -> C {
    return fn(arg, b)
    }
    return apply
    }

    func add(x: Int, y: Int) -> Int {
    return x + y
    }

    let addThree = fp(add, 3)

    addThree(0)
    addThree(1)
    addThree(2)
    addThree(3)