
16 Mar
2016
16 Mar
'16
11:44 p.m.
On 17/03/16 3:58 pm, Krisztian Pinter wrote:
I think the reasonable behaviour would be [1,1..1] == [1]. Is there a reason it doesn't work like this? That's arguably *a* reasonable behaviour, but I'm not sure it's *the* reasonable behaviour. Another reasonable behaviour would be a run-time error for [X,X..Y] whatever Y is. And to my mind, what Haskell actually does, while not as programmer-friendly as a run-time error would be, is reasonable because consistent.
In R,
seq(from=1, to=2, by=0) Error in seq.default(from = 1, to = 2, by = 0) : invalid (to - from)/by in seq(.) seq(from=1, to=1, by=0) [1] 1
I find this behaviour in R inconsistent and confusing. At least in Haskell [1,1..N] gives the same answer for any N >= 1.