newbie conceptual question [from haskell list]
Thu, 26 Jul 2001 11:55:01 +0100 (BST)
On Thu, 26 Jul 2001, Frank Atanassow wrote:
> also safety, and "theorems for free". Then there are other properties
> are obvious (to a programmer) in a Haskell program which get buried in
> equivalent C(++) program, e.g., that every member of a data structure is
> traversed in a fold ("no early exits"). Many of these things hinge on
> typing of a program, which is inferred and checked for you, so there is
> of a burden on conscientious programmers.
I'm being terribly unfair here; this was probably just a simple slip when
writing a hurried e-mail but if you mean what I think you mean about the
undefd = undefd
f y x|y=='a' = "finished"
|otherwise = y:x
g xs = foldr f "" xs
Main> g ('a':undefd)
shows that folds can exit early; if it didn't it'd black hole forever.
www.cs.bris.ac.uk/~tweed/pi.htm |tweed's law: however many computers
email: firstname.lastname@example.org | you have, half your time is spent
work tel: (0117) 954-5250 | waiting for compilations to finish.