30 Mar
2004
30 Mar
'04
3:48 p.m.
tis 2004-03-30 klockan 17.30 skrev S. Alexander Jacobson:
I would assume that this function:
foo list@(h:t) = list
is equivalent to
foo list = list where (h:t)=list
But passing [] to the first generates an error even though h and t are never used! Passing [] to the second works just fine.
You can write this as
foo' list@(~(h:t)) = list
foo' [] will evaluate to []. The H98 report calls it an "irrefutable pattern", IIRC. Regards, Martin