[Haskell-cafe] Shouldnt this be lazy too?

Henning Thielemann lemming at henning-thielemann.de
Tue Sep 25 04:51:13 EDT 2007


On Mon, 24 Sep 2007, Neil Mitchell wrote:

> Hi
>
>>>> In this world, use "length (take 11 [1..]) > 10"...
>>>>
>>> not (null (drop 10 [1..])) is surely faster (not tested...)
>>>
>> Faster? There might be a few microseconds in it.
>>
>> Clearer? Possibly... ;-)
>
> lengthNat [1..] > 10
>
> Couldn't be clearer, and can be made to work perfectly. If anyone does
> want to pick up the lazy naturals work, I can send over the code (or
> write it yourself - its not hard!)

E.g.
  http://darcs.haskell.org/htam/src/Number/PeanoNumber.hs


More information about the Haskell-Cafe mailing list