Accessing a column from a vector of vectors

Hi,

I have something like:

a = [["a", "1" ,"11"],
     ["b", "2" ,"22"],
     ["c", "3" ,"33"]]

3-element Vector{Vector{String}}:
 ["a", "1", "11"]
 ["b", "2", "22"]
 ["c", "3", "33"]

And I would like to get e.g. the “a, b, c” or “1, 2, 3” vectors.
Tried various [:,:][…] combos with success.

Are you looking for something more sophisticated than the following?

julia> map(v -> v[1], a)
3-element Vector{String}:
 "a"
 "b"
 "c"

Nope, I wondered if the [:,:] kind of syntax would be usable.
Working fine, thanks.

julia> getindex.(a,1)
3-element Vector{String}:
 "a"
 "b"
 "c"

also works

And in the specific case for the a, b, c vector

julia> first.(a)
3-element Vector{String}:
 "a"
 "b"
 "c"

(or last for the last “column”, but getindex more generally as mentioned above)

[a...;;][1,:]
[a...;;][2,:]

Another method could be:

julia> using IterTools

julia> nth.(a, 1)
3-element Vector{String}:
 "a"
 "b"
 "c"

Note the broadcasting used with nth (that is nth.(...)).

Also:
stack(a)[1,:]

And:

using TensorCast
@cast b[i] := a[i][1]

What are the drawbacks to defining a specific syntax for this case?
For example like a[:][1]

Well, the syntax a[:][1] already exists: it copies a and then selects that copy’s first element.

More generally, a Vector{Vector} is not a Matrix (e.g. it can be ragged), so it’s not the natural concept to use when talking about things like columns.