"Richard A. O'Keefe" <[EMAIL PROTECTED]> writes: > Erlang's equivalent of [m..n] is lists:seq(M, N), > which is currently defined to raise an exception when N < M. > In particular, lists:seq(1, N) returns a list of length N > when N > 0, but not when N = 0. > 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. > > In Haskell, > "The sequence enumFromTo e1 e3 is the list [e1,e1+1,e1+2,...e3]. > The list is empty if e1 > e3." > > It is being claimed that the reason for this is that "exceptions > are problematic" in Hasell, so the Haskell designers went out of > their way to make this function total whether it made sense or not.
I'm pretty sure that's not true. I'd like to be able to say "I know, I was there", but although I was there it was so long ago that my memory isn't clear. But it's clearly the case that [5 .. 6] is [5, 6] (length 2) and [5 .. 5] has to be [5] (length 1), so it's not unreasonable to expect that [5, 4] be [] (length 0) -- having the induction extend down to there makes most sense. I'm fairly certain it was arguments about induction and what constituted sensible behaviour rather than our admitted dislike for exceptions that carried the argument. -- Jón Fairbairn [EMAIL PROTECTED] _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe