On Sat, Jul 19, 2003 at 11:23:04PM +0900, Pit Capitain wrote:
> I'm not Dave Thomas :-) but you can also use inject here:
> 
> module Enumerable
>   def ordered?
>     inject { | last, item | return false unless last < item; item }
>     true
>   end
> end

Which implementation of 'inject' are you using? The one in PragProg requires
an initial value to be passed as a parameter.

With an array of N elements you either need to do N-1 comparisons, or you
need to start with a sentinel value which is guaranteed to be less than all
other elements (nil and 0 both aren't suitable). So I don't see how the
above works, but without its partner 'inject' implementation I can't comment
further.

Regards,

Brian.