[clean-list] Exercise from Clean book

Daniel Yokomiso daniel_yokomiso@yahoo.com.br
Mon, 15 Sep 2003 21:54:10 -0300


Hi,

    I'm having some problem with exercise 2 from chapter two of Functional
Programming in CLEAN (Draft - september 10, 2001). The question is:


"Execute the start expression given in section 2.4.2. Rewrite the program
such that it only prints the smallest number that is different from zero
using the function until."


where the expression from section 2.4.2 is:


takeWhile ((<>) 0.0) (iterate (\x -> x/10.0) 1.0)


    So far so good, I come up with the following definitions:


expected = last (takeWhile ((<>) 0.0) (iterate (\x -> x/10.0) 1.0))
smallest = until (\x -> tenth x == 0.0) tenth 1.0
tenth x  = x/10.0

Start = expected == smallest


    After running it the system gives me "False". I checked the output of
"smallest" and it's "0". Surprised I also checked it in Haskell (Hugs 98)
and it's ok (expected == smallest). What's happening here? I'm using the
Clean IDE v2.0 build 2001-12-18 Win (2.0) 2.0.1.42.

    Best regards,
    Daniel Yokomiso.

"Being right too soon is socially unacceptable."
 - Robert A. Heinlein


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.518 / Virus Database: 316 - Release Date: 11/9/2003