[Haskell-cafe] basic haskell question
Hamilton Richards
ham at cs.utexas.edu
Sun May 22 16:46:40 EDT 2005
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
ham at cs.utexas.edu hrichrds at swbell.net
http://www.cs.utexas.edu/users/ham/richards
------------------------------------------------------------------
More information about the Haskell-Cafe
mailing list