-
-
Save nonamenix/9038098 to your computer and use it in GitHub Desktop.
CoffeeScript / Zip function for dict comprehension
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
zip = (pairs) -> | |
dict = {} | |
dict[key] = value for [key, value] in pairs | |
dict | |
# Example | |
zip ([el, el * el] for el in [4..8]) # {4:16, 5:25, 6:36, 7:49, 8:64} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment