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

Ertugrul Söylemez es at ertes.de
Tue May 22 03:02:10 CEST 2012


AntC <anthony_clayden at clear.net.nz> wrote:

> 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: [])

I tend to use bracket notation for fixed-length list patterns.


> 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)?

Yes.  It's quite seldom that I use bracket notation, though.  That's
simply because it's seldom that I pattern-match against fixed-length
lists.


Greets,
Ertugrul
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://www.haskell.org/pipermail/beginners/attachments/20120522/6f172adf/attachment.pgp>


More information about the Beginners mailing list