Discussion:
Ragged / Jagged arrays
asim
12 years ago
Permalink
Hi

I am new to Julia. Does Julia support Jagged or Ragged arrays?

Thanks

Asim
John Myles White
12 years ago
Permalink
One way to get a ragged array is to use an Any Array of Array's like:

{
[1, 2, 3],
[4, 5]
}

Does that suit your purposes?

-- John
Post by asim
Hi
I am new to Julia. Does Julia support Jagged or Ragged arrays?
Thanks
Asim
Stefan Karpinski
12 years ago
Permalink
I'm not sure there's better ways to support ragged arrays. Unless a sparse
array is really what you want.
Post by John Myles White
{
[1, 2, 3],
[4, 5]
}
Does that suit your purposes?
-- John
Post by asim
Hi
I am new to Julia. Does Julia support Jagged or Ragged arrays?
Thanks
Asim
asim
12 years ago
Permalink
Thanks. This looks very useful.

One more thing. How do I get the position of an entry within an array?

For example, suppose we have an array m=[ "a", 'b", "c"]. These could be
the names of variables in a dataset. Suppose I want to get an index, 3 (as
it is the third column) for "c". In Mathematica, we can use Position[m,
"c"]. Is there a similar function in Julia?


Thanks for all your help.

Asim
Post by asim
Hi
I am new to Julia. Does Julia support Jagged or Ragged arrays?
Thanks
Asim
John Myles White
12 years ago
Permalink
Try indexin:

julia> indexin(["x", "c"], ["a", "b", "c", "d", "x"])
2-element Array{Int64,1}:
5
3
Post by asim
Thanks. This looks very useful.
One more thing. How do I get the position of an entry within an array?
For example, suppose we have an array m=[ "a", 'b", "c"]. These could be the names of variables in a dataset. Suppose I want to get an index, 3 (as it is the third column) for "c". In Mathematica, we can use Position[m, "c"]. Is there a similar function in Julia?
Thanks for all your help.
Asim
Hi
I am new to Julia. Does Julia support Jagged or Ragged arrays?
Thanks
Asim
asim
12 years ago
Permalink
Thanks a lot. indexin is perfect.

Asim
Post by asim
Hi
I am new to Julia. Does Julia support Jagged or Ragged arrays?
Thanks
Asim
Continue reading on narkive:
Loading...