Previous Up Next

6.3.29  Applying a bivariate function to the elements of two lists

The zip command applies a bivariate function to the elements of two lists.

Examples

zip('sum',[a,b,c,d],[1,2,3,4])
     

a+1,b+2,c+3,d+4
          
zip((x,y)->x^2+y^2,[4,2,1],[3,5,1])

or:

f:=(x,y)->x^2+y^2:; zip(f,[4,2,1],[3,5,1])
     

25,29,2
          
f:=(x,y)->[x^2+y^2,x+y]:; zip(f,[4,2,1],[3,5,1])
     



257
297
22



          

Previous Up Next