
16 Aug
2007
16 Aug
'07
5:29 p.m.
On 2007-08-16, Neil Mitchell
Hi
So what I noticed that "A Gentle Introduction to Haskell" mentioned that wild-cards are useful in constructors. For example:
head (x:_) = x
So, does that offer any performance benefits over:
head (x:xs) = x
No. They are exactly the same. _ simply means "a new unique name".
Or is it primarily to indicate to the coder that xs is useless?
Yes
And to the compiler that the name won't be used, so it needn't warn you about not using it. -- Aaron Denney -><-