<p>I'm wondering if there's a way to do what I can do below with Python, in Ruby:</p>

<pre><code>sum = reduce(lambda x, y: x + y, map(lambda x, y: x * y, weights, data))
</code></pre>

<p>I have two arrays of equal sizes with the weights and data but I can't seem to find a function similar to map in Ruby, reduce I have working.</p>

The Array.zip function does an elementwise combination of arrays. It's not quite as clean as the Python syntax, but here's one approach you could use:
```
```
weights = [1, 2, 3]
data = [4, 5, 6]
result = Array.new
a.zip(b) { |x, y| result << x * y } # For just the one operation

sum = 0
a.zip(b) { |x, y| sum += x * y } # For both operations
```
```