[clean-list] stupid question

David Minor david-m at orbotech.com
Tue Dec 11 09:46:45 MET 2007


I must be missing something obvious, I'm going through the tutorial, why
doesn't the following terminate on a one digit number when given 999 as
expected?

 

module test

import StdEnv

 

Start = [isum 18, isum 3, isum 999]

 

isum :: Int -> Int

isum x

            | x<10 = x

            | otherwise = ones x + isum (x / 10)

 

div9 :: Int -> Bool

div9 x

            | isum x == 9 = True

            | otherwise = False

            

ones :: Int -> Int

ones x = (x - ((x / 10) * 10))

 

Thanks,

David

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.science.ru.nl/pipermail/clean-list/attachments/20071211/099cbe80/attachment.html


More information about the clean-list mailing list