At 12:50 AM +0800 2005/5/23, wenduan wrote:
hi,
Anybody could please tell me that in the following two expressions what value does the [] take?

foldl (/) 3 []
foldr (/) 3 []

when both of them are evaluated I got 3.0,but I thought I could get nothing out of there,cause its an empty list,does Haskell assume any default value for a empty list?

A quick check of the equations that define foldl and foldr (see Prelude.hs) shows that when either of them has an empty list for its third argument, it returns its second argument.

Regards,

--Ham
--
------------------------------------------------------------------
Hamilton Richards, PhD           Department of Computer Sciences
Senior Lecturer                  The University of Texas at Austin
512-471-9525                     1 University Station C0500
Taylor Hall 5.138                Austin, Texas 78712-0233
[EMAIL PROTECTED]                [EMAIL PROTECTED]
http://www.cs.utexas.edu/users/ham/richards
------------------------------------------------------------------
_______________________________________________
Haskell-Cafe mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/haskell-cafe

Reply via email to