[Haskell-cafe] [m..n] question
wren ng thornton
wren at freegeek.org
Sun Sep 21 23:17:05 EDT 2008
ajb at spamcop.net wrote:
> Having said that, I don't know of a good reason why [5,5..5] is an
> infinte list of 5's.
I'm sure you know *why* it's an infinite list[1], but as for why that's
useful I can't say. It has the feel of a bug in implementation, though
it is ...consistent.
As for the OP, like Python, Perl also takes [m..n] to be [] when n < m.
They may not be as principled as Haskell or Erlang, but it does seem to
be the consensus view.
[1] Because the "5,5.." yields an (unfoldr (Just . (\x -> (x,x)) . (+0))
5) stream but the "..5" only causes termination just as soon as the
stream is surpassing 5, which it never will.
--
Live well,
~wren
More information about the Haskell-Cafe
mailing list