[Haskell-cafe] Re: map (-2) [1..5]

Aaron Denney wnoise at ofb.net
Mon Sep 11 12:14:51 EDT 2006


On 2006-09-10, Neil Mitchell <ndmitchell at gmail.com> wrote:
> Hi,
>
>> I think in practice this wouldn't really be an issue. When you're
>> using natural numbers, you tend to be in a situation where you're
>> either numbering things statically, and not doing any calculations
>> with them, or you're using them as a monoid, whereby things only
>> increase.
>
> take? primes? fibs? ackermanns?

take is more an iteration than a numerical calculation -- it works best
as pattern matching on Succ and Zero.

Primes and fibs are purely generative streams that can be calculated
just fine using integers.  If you want to geta specific value out, then
sure, index using naturals, which again is a data-structural induction.

Yes, it's nice to be able to encode the invariant "x > 0".  It'd also
be nice to be able to encode invariants like (x > 10), or (a < x < b)
for array access.  But for both of these it is more natural to work with
a subset of the integers, than a new type.  Yes, even if this means
dealing with partial functions.

And, as I pointed out before, if naturals are represented asunary, then
it means you can do "take infinity xs where infinity = Succ infinity"

> See "What About the Natural Numbers" - "Colin Runciman" - it's a good read :)

I will when I get the chance.

-- 
Aaron Denney
-><-



More information about the Haskell-Cafe mailing list