Initialize row vector multiple lines

Dear Community,
I am trying to achieve the same result of [1 2 3], with a code spanning over multiple lines, i.e.
[1
2
3]

However, the latter code returns a column vector.
Since the population of the array is long, it is not possible for me to use the [1 2 3] approach in a single line, iwthout multipling significantly the number of lines to write.
Is there an efficient way to do so?

Thank you,
Davide

You can use

hcat(1,
2,
3)

which should produce the needed result.

2 Likes

Anything against using transpose()?

2 Likes

You can also use multiline comments #= ... =# to eliminate the line break, e.g.

x = [1 2 3 #=
  =# 4 5 6]

See also this discussion: Feature request: add operator to allow break lines in matrix definition · Issue #27533 · JuliaLang/julia · GitHub

3 Likes

Thank you for your answers, both the solution by @Skoffer and @stevengj answer my problem.
Thank you

2 Likes

I was wondering about it, but I was looking for a more clean solution.
Thank you by the way, this solves the problem as well