Is there some language where [4,6] is the output? That strikes me as serving some use case that I've never come across. Whereas having two lists and wanting to end up with one list with all the elements is a very common need.
I believe it would be in Matlab, as [1, 2] + [3, 4] would be considered matrix addition, in which one adds elements in corresponding places. Numpy (as mentioned in the GP) probably does similar.
Comments
Is there some language where [4,6] is the output? That strikes me as serving some use case that I've never come across. Whereas having two lists and wanting to end up with one list with all the elements is a very common need.
I believe it would be in Matlab, as [1, 2] + [3, 4] would be considered matrix addition, in which one adds elements in corresponding places. Numpy (as mentioned in the GP) probably does similar.
Ah, ok, thanks. Right, matrix math is is the use case I was looking for.
Yes, python.
we are talking about Lists, not arrays from an unrelated library which has to be installed first. what you've done there is simply dishonest
In [1]: a = [1,2]
In [2]: b = [4,5]
In [3]: print(a+b)
Out [1, 2, 4, 5]
Is there some language where [4,6] is the output?
Yes. Python:
For extra fun: but, of course:In R:
[1] 4 6
[1] "array"