Last active
March 22, 2018 13:25
-
-
Save dharasim/4b80e70a78991ede5a1760aa3da91f8e to your computer and use it in GitHub Desktop.
generic unzip function in julia
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
""" | |
unzip(iter) | |
unzip an iterable object of indexable objects | |
""" | |
function unzip(iter) | |
ntuple(length(first(iter))) do i | |
map(iter) do indexable | |
getindex(indexable, i) | |
end | |
end | |
end | |
# test | |
unzip([(1,2,3), (11,22,33)]) == ([1, 11], [2, 22], [3, 33]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment