From: "Ara.T.Howard" Date: 2005-08-06T04:31:07+09:00 Subject: Re: algorithm help On Sat, 6 Aug 2005, daz wrote: > > Ara.T.Howard wrote: >> On Fri, 5 Aug 2005, Robert Klemme wrote: >> >>> Btw, here's another funny idea: >>> [snip code] >> >> not bad (and *so* short), but failing for descending ranges [...] >> > > > Descending ranges don't have much method support in Ruby, though. > > rg = (43..41) > > p rg.include?(42) #-> false > p rg.max #-> nil > p rg.to_a #-> [] > > .... and others. but harp:~ > irb -r narray irb(main):001:0> na = NArray::to_na [1,2,3,4] => NArray.int(4): [ 1, 2, 3, 4 ] irb(main):002:0> na[ -3 .. -1 ] => NArray.int(3): [ 2, 3, 4 ] irb(main):003:0> na[ -1 .. -3 ] => NArray.int(3): [ 4, 3, 2 ] which is precisely what i'm doing. cheers. -a -- =============================================================================== | email :: ara [dot] t [dot] howard [at] noaa [dot] gov | phone :: 303.497.6469 | My religion is very simple. My religion is kindness. | --Tenzin Gyatso ===============================================================================