From: serialhex Date: 2012-04-14T12:34:23+09:00 Subject: Re: unable to do "down" range? --90e6ba25db95c86c9604bd9b4341 Content-Type: text/plain; charset=ISO-8859-1 On Apr 13, 2012 5:04 PM, "Ralph Shnelvar" wrote ... > As I understand the code right now, > > (1..10_000_000).last(5) # [9999996, 9999997, 9999998, 9999999, 10000000] > > will create a temporary array of ten million elements and then peel off the last five array elements. > > Now from my perspective, having to allocate that relatively huge temporary array is awful; truly Rube Goldberg-esque. ... This can be done with lazy evaluation... take a look at haskell, though in some ways it is the arch-nemesis of ruby, it is a very cool language with some awesome features! And porting some of those features (like lazy eval) would be pretty cool imho... hex snt frum my awesum ansroid... txt mite b rong --90e6ba25db95c86c9604bd9b4341 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable

On Apr 13, 2012 5:04 PM, "Ralph Shnelvar" <ralphs@dos32.com> wrote
...
> As I understand the code right now,
>
> =A0(1..10_000_000).last(5) # [9999996, 9999997, 9999998, 9999999, 1000= 0000]
>
> will create a temporary array of ten million elements and then peel of= f the last five array elements.
>
> Now from my perspective, having to allocate that relatively huge tempo= rary array is awful; truly Rube Goldberg-esque.
...

This can be done with lazy evaluation... take a look at haskell, though = in some ways it is the arch-nemesis of ruby, it is a very cool language wit= h some awesome features! And porting some of those features (like lazy eval= ) would be pretty cool imho...

hex

snt frum my awesum ansroid... txt mite b rong

--90e6ba25db95c86c9604bd9b4341--