B
Bertram Scharpf
Hi,
Am Sonntag, 07. Aug 2005, 18:06:07 +0900 schrieb walter a kehowski:
As long as you can be sure your arrays have the same length
you could use Array#transpose:
va = [ 3, 5, 8, 7, 20]
vb = [ 4, 12, 15, 24, 21]
vc = [ va, vb].transpose
vc.map { |a,b| Math.sqrt a*a+b*b }.each { |c| puts c }
Bertram
Am Sonntag, 07. Aug 2005, 18:06:07 +0900 schrieb walter a kehowski:
How would I create a function that will take list (array) of integers and
return their cartesian product?
As long as you can be sure your arrays have the same length
you could use Array#transpose:
va = [ 3, 5, 8, 7, 20]
vb = [ 4, 12, 15, 24, 21]
vc = [ va, vb].transpose
vc.map { |a,b| Math.sqrt a*a+b*b }.each { |c| puts c }
Bertram