[Haskell-cafe] [m..n] question

ajb at spamcop.net ajb at spamcop.net
Sun Sep 21 21:00:24 EDT 2008


G'day all.

Quoting "Richard A. O'Keefe" <ok at cs.otago.ac.nz>:

> I'm currently arguing that lists:seq(1, 0) should be [],
> not an exception.  Oddly enough, I'm being beaten over the
> head with Haskell, of all things.
[...]
> Does anyone remember why the definition of enumFromTo is the way it is?

I don't know if this is the reason, but there's another nice property
that enumerations have, namely:

     [p..q-1] ++ [q..r-1] == [p..r-1]  -- if p <= q <= r

If you think of the abstract semantics of ranges, this makes perfect
sense.  There needs to be a notation for empty ranges.

Having said that, I don't know of a good reason why [5,5..5] is an
infinte list of 5's.

Cheers,
Andrew Bromage


More information about the Haskell-Cafe mailing list