bloom-lang / bud

Prototype Bud runtime (Bloom Under Development)
http://bloom-lang.net
Other
854 stars 59 forks source link

Make Max and Min aggs use <=> instead of > or < #308

Closed aarondav closed 11 years ago

aarondav commented 11 years ago

This comparator is more general, and accepts types like Arrays. This is really useful for vectors, so we can now take the max of vectors like [1, 2, 3] and [1, 2, 4].

Also added the same duplication case from Min for Max as well. I'm not certain why they were different, but I can't think of a reason why max should not return all maximum results, rather than an arbitrary one.

This change is motivated by our CS194-17 project and, uh, our solution won't run if this isn't patched. So we hope you find the change good!

neilconway commented 11 years ago

Weird; Array provides <=> but does not include Comparable. Apparently this is the "best compromise" (http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/22373), but it doesn't make a lot of sense to me.

Anyway, no objection to merging this from me.