Let me start by saying I really like Ruby iterators - anyhow I've been taking every opportunity to use the single line syntax like: StopWord.find(:all).each{ |x| @stop_words << x.stopword } yea! But I came across one that I couldn't quite figure out.. The basic idea is called a 'dot product' or 'simple matching' - it's a way to determine simularities in vector space models - that's not important tho.. I'm looking for a way to iterate over two arrays and sum or multiply or whatever each element resulting in a new array of the summed elements, e.g. a[0]+b[0], a[1]+b[1], ... a[n]+b[n] This is what I'm currently using - it works but def lacks the eloquence of single line iterators: #assumes equal size arrays! def dotproduct(doc, query) @product = Array.new(doc.length) @i = 0 doc.each do |term| @product[@i] = term * query[@i] @i += 1 end return sum(@product) end Any thoughts on getting this into single-line syntax? Just curious. Thanks. -- Posted via http://www.ruby-forum.com/.