Created
July 19, 2012 08:16
-
-
Save owainlewis/3141531 to your computer and use it in GitHub Desktop.
Partial Function Application
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defn add [a b] (+ a b)) | |
(def addTwo (partial add 2)) | |
(addTwo 5) | |
(map addTwo [1 2 3]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Partial Functions | |
from functools import partial | |
def add(a, b): | |
return a + b | |
def addTwo = partial(add, 2) | |
addTwo(5) | |
# Mapping partial functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Ruby partial |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment