Every expression could be acted on, so you can use
([1 2 3] * [4; 5; 6])[1]
to get the first (and only value out).
There are major performance reasons for this: type-stability. Basically, in a compiled language you cannot change your types around without doing a bunch of conversions. Julia is a bit smarter, though if you do a bunch of conversions, then your code will be slower since the compiler will have to keep around a lot of "kruft" just in case you have the wrong type. Thus by ensuring type-stability, the compiler can know in advance what the type will be, and do a lot more optimizations. This is one of the performance tips. Indeed, Julia is fast and reaches C speeds BECAUSE of multiple dispatch and type-stability, and so it should be respected.
Array * Array gives out an array. In order for that to be type-stable, it must always give out an array. Otherwise the compiler needs to put extra code to check if that variable is an array or not... at every place where the output is used! So then you should use * with arrays to get arrays out. If you want to get a scalar out, the easy answer is use the dot function:
dot([1;2;3],[4;5;6])
Of course I could've just said that, but it's good to know the "why" since type-stability is such an important idea for performant code.
[1 2 3]is a 1x3 2D Array. Therefore multiplying a 2D array by a 1D array gives a 1D array, as a matrix by vector multiply should. As @Chris Rackauckas mentioned usingdot()gives a scalar.\cdot<TAB>will produce the dot operator⋅which is shorthand fordot(...). Thus, the expression in the OP can be written:vec([1 2 3])⋅[4;5;6]. Note[1 2 3]still needs to be turned to a 1D vector.dot, because it takes vectors, so the first argument needs to be converted, as you said. So the efficient version is still to take the first element of the matrix multiplication.[1 2 3][:]⋅[1;2;3]