-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Open
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requests
Description
Hi there,
apologies if this has already been addressed somewhere, but is there a reason that there is no unzip() function in Base?
Ideally this would be a function that would take a Vector{Tuple{ ... }} and return a Tuple{Vector, ..., Vector} for output. E.g.
julia> v = [(1,"a",:meow), (2,"b",:woof), (3,"c",:doh!)]; unzip(v)
([1,2,3],ASCIIString["a","b","c"],[:meow,:woof,:doh!])
A naive implementation might be something like
function unzip(input::Vector)
n = length(input)
types = map(typeof, first(input))
output = map(T->Vector{T}(n), types)
for i = 1:n
@inbounds for (j, x) in enumerate(input[i])
(output[j])[i] = x
end
end
return (output...)
endsbromberger, tlnagy, iamed2, HarrisonGrodin, sosiristseng and 13 more
Metadata
Metadata
Assignees
Labels
featureIndicates new feature / enhancement requestsIndicates new feature / enhancement requests