Last active
April 24, 2021 10:42
-
-
Save kraftdorian/1bb11d9b9fa8cdd57104c8c477c13467 to your computer and use it in GitHub Desktop.
Tuple in JavaScript written in Scala style
This file contains hidden or 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
const tuple = (...atoms) => Object.freeze( | |
atoms.reduce((partial, atom, index) => ({ | |
...partial, | |
['_' + ++index]: atom | |
}), {}) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Use case
Result: