From: Todd Benson Date: 2007-07-27T14:32:42+09:00 Subject: Re: beginner Q. On 7/26/07, Erik Boling wrote: > Pe�a, Botp wrote: > > From: Erik Boling [mailto:schmode93@yahoo.com] > > # 1.5 and -1.0 thing. It would be neat if it could just print *buy from > > # vendor #1" or "buy from vendor #2" *saying that you always > > # want to buy the cheapest, positives = vendor 2 is cheapest, negitaves, > > # obviosly vendor #1 is the cheapest* > > > > why don't you just compare their averages? > > > > kind regards -botp > > you mean like the avarage of all the items together from each vendor, if > so... Well im not sure how much you know about the food industry, but, > overtime if you dont find the cheapest prices, it adds up quick, > epecially when your running a big catering company like my dad :P. But i > was thinking.. couldn't i put if and elsifs for it to work??? Also look at case-when and <=> For example, v1, v2 = [10, 9, 12], [8, 9, 13] best = a.zip(b).map do |pair| case pair[0] <=> pair[1] when -1 then 'vendor a' when 0 then 'same' when 1 then 'vendor b' end end Eventually, you might want to use Hashes... v1 = { :onions => 0.70, :carrots => 0.88 } v2 = { :onions => 0.78, :carrots => 0.87, :celery => 0.61 } And other cool stuff like that :) Todd