Previous Up Next

2.38.3  Term by term sum of two lists : + .+

The infixed operator + or .+ and the prefixed operator ’+’ returns the term by term sum of two lists.
If the two lists do not have the same size, the smallest list is completed with zeros.
Note the difference with sequences : if the infixed operator + or the prefixed operator ’+’ takes as arguments two sequences, it merges the sequences, hence return the sum of all the terms of the two sequences.
Input :

[1,2,3]+[4,3,5]

Or :

[1,2,3] .+[4,3,5]

Or :

’+’([1,2,3],[4,3,5])

Or :

’+’([[1,2,3],[4,3,5]])

Output :

[5,5,8]

Input :

[1,2,3,4,5,6]+[4,3,5]

Or :

’+’([1,2,3,4,5,6],[4,3,5])

Or :

’+’([[1,2,3,4,5,6],[4,3,5]])

Output :

[5,5,8,4,5,6]

Warning !
When the operator + is prefixed, it should be quoted (’+’).


Previous Up Next