[Haskell-cafe] List syntax -- [] vs ()

Crypt Master cryptmaster at hotmail.com
Sat Jul 3 05:35:05 EDT 2004


Hi

Thanks. A light bulb just went on :). I am still in awe of how much "special 
syntax" is made of such simple base. Haskell certainly is an interesting 
thing to learn, its like fractals, complexity and beuty from simplicity.

S

----Original Message Follows----
Crypt Master,

   CM> I have noticed that lists seem to swtich between
   CM> using [] and  using (). for example:
   CM>
   CM> listSum [] = 0
   CM> listSum (x:xs) = x + listsum xs

The parentheses are just 'normal' parentheses that are needed because
application binds stronger than (:). Without the parentheses, you would get

   listSum x : xs

which is the same as

   (listSum x) : xs .

HTH,

Stefan

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 
http://join.msn.com/?page=features/virus



More information about the Haskell-Cafe mailing list