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

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


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.


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

   CM> I have noticed that lists seem to swtich between
   CM> using [] and  using (). for example:
   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 .



MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*. 

More information about the Haskell-Cafe mailing list