[Haskell-beginners] [x] and (x:_) for lists -- did you ever think that odd?

AntC anthony_clayden at clear.net.nz
Tue May 22 02:49:40 CEST 2012


Ertugrul Söylemez <es <at> ertes.de> writes:

[snip ..]
>   We have access to the two list constructors (:) and []
> directly and they are very convenient,

So Ertugrul, as an experienced Haskeller which of these do you put in your 
code for a singleton list (whether appearing in a pattern or as an expression):
    [x]
    (x: [])

Or perhaps you mix them, depending on whether you want to be more suggestive 
of an empty list [] or an unknown-length list (x: xs)?

[.. snippety-snip]

AntC





More information about the Beginners mailing list