On Mon, 21 Jul 2003 14:54:10 +0200, Robert Klemme wrote:

> 
> An alternative
> 
> def less(*args); compare_chain(proc{|a,b|a<b}, *args); end
> def greater(*args); compare_chain(proc{|a,b|a>b}, *args); end
> 
> def compare_chain(comp, *args)
>   last = nil
> 
>   args.each do |i|
>     return false if last and not comp.call(last,i)
>     last = i
>   end
> 
>   true
> end
> 
> less 1,10,22
> less 2,1,14
> less -2,1,14
> greater 10,3,-100
> greater 2,1,14

OK.. this is the nicest solution so far :-)

I didn't thought of using proc's for binary compares.

--
Simon Strandgaard