Last active
December 20, 2015 09:29
-
-
Save strager/6107955 to your computer and use it in GitHub Desktop.
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
function tuple(/* ... */) { | |
var args = arguments; | |
return function unpackTuple(f) { | |
return f.apply(this, args); | |
}; | |
} | |
var t = tuple(1, 2, 3); | |
t(function (a, b, c) { | |
return {a:a, b:b, c:c}; | |
}); | |
// => {a:1, b:2, c:3} | |
t(Array); // Be careful with one-element tuples! | |
// => [a, b, c] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment