I am a newer to julia, and cannot understand the use of three dot although have read some documents.
For example as follows: A is two elements vector of (x,y); B is six elements vector of (1,2,3,4,5,6); C is four elements vector of (1,2,3, y) and D is four elements vector of (x,4,5,6).
How do I understand
Thank you very much for your help.
x, y = [1,2,3], [4,5,6]
A = [x, y]
B = [x..., y...]
C = [x..., y]
D = [x, y...]
Could you explain what exactly you have trouble with? I’m assuming you have read
Frequently Asked Questions · The Julia Language…-operator-do?
which explains what splatting is, and it seems (at least to me!) that you’ve got a good set of examples already:
julia> A = [x, y]
[1, 2, 3]
[4, 5, 6]
julia> B = [x..., y...]
when we splat an argument it should be read as if each element of the splatted collection is a separate function argument, i.e.:
julia> [x..., y...] == [x, x, x, y, y, y]
Thank you, nilshg, I have known the meaning of splatting, it treat each element in the vector as a new, separate element. I was very curious about this example just now, and I couldn’t understand the instructions in the manual.
Thank you very much for your immediately reply.