Jonathan Cast wrote:
On Sat, 2008-09-27 at 02:09 +0100, Simon Richard Clarkstone wrote:
Darn, I sent this as personal mail the first time.
Evan Laforge wrote:
In Haskell,
"The sequence enumFromTo e1 e3 is the list [e1,e1+1,e1+2,...e3].
The list is empty if e1 > e3."
I like it, since it means that things like [n .. n + length m - 1]
work as expected when m is []. Or say 'map (array!) [bsearch x ..
bsearch y - 1]'.
Tangent: Of course, I would prefer the range be half-open, which is a
pretty consistent standard in the rest of the world. I've had a
number of off by one errors from this, and from Array.bounds. I guess
it's too late to fix those, though, even if there were agreement that
they need to be fixed.
It causes problems with types that have an upper bound. You can't
express Haskell's [False .. True] as a half-open range for example.
[False .. ] works great, though, whether ranges are closed or half-open.
You get problems though if you want to tell a function about a range,
passing in a low and a high by some means, and it is expecting a
half-open range, but you want to tell it [False..]. For example,
creating a new array.
BTW, why isn't [..] the notation for the entirety of a Bounded type?
---
This mailing list is odd; thunderbird defaults to replying to sender
rather than to the whole list.
--
src/
_______________________________________________
Haskell-Cafe mailing list
Haskell-Cafe@haskell.org
http://www.haskell.org/mailman/listinfo/haskell-cafe