Previous Up Next

14.1.3  Term by term sum of two lists

The infixed operators + and .+ as well as the prefixed operator ’+’ return the term by term sum of two lists. If the two lists do not have the same size, the smaller list is padded with zeros.

Note the difference with sequences: if the infixed operator + or the prefixed operator ’+’ is applied to two sequences, it merges the sequences, hence return the sum of all the terms of the two sequences.

Examples

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

or:

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

or:

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

5,5,8
          
[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]])
     

5,5,8,4,5,6
          
Remark.

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


Previous Up Next