really silly question

Duane Maxwell dmaxwell at san.rr.com
Fri Aug 31 03:14:47 UTC 2001


> Given two arrays of the same size filled with numbers, can someone give
> me a code snippet that will show me how to add the numbers at the same
> index to produce a third array?
> 
> So that firstArray:= #(1 2 3 4)
> secondArray:= #(5 6 1 2)
> 
> will result in a thirdArray (6 8 4 6)

How about:

thirdArray := firstArray with: secondArray collect: [:a :b | a+b]

-- Duane





More information about the Squeak-dev mailing list