--- Square root v8: using Haskell's iterate control abstraction
sqrt8 x = head (dropWhile (not . goodEnough) sqrtGuesses)
where
goodEnough guess = abs (x - guess*guess)/x < 0.00001
improve guess = (guess + x/guess)/2.0
sqrtGuesses = iterate improve 1
{-- To test it:
sqrt8 10
--}
sqrt8guesses x = iterate improve 1
where
improve guess = (guess + x/guess)/2.0
{-- To test it:
take 5 (sqrt8guesses 10)
--}