[clean-list] stupid question

Cristian Baboi cristi at ot.onrc.ro
Tue Dec 11 10:00:05 MET 2007


On Tue, 11 Dec 2007 10:46:45 +0200, David Minor <david-m at orbotech.com>  
wrote:

> 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?

I don't know what is expected, but it sums the digit of numbers given in  
the lists.
1+8=9
3 = 3
9+9+9 = 27


> 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
>
>
>
>
>
> ________ Information from NOD32 ________
> This message was checked by NOD32 Antivirus System for Linux Mail  
> Servers.
>    - is OK
>   part000.txt - is OK
>   part001.htm - is OK
>   part001.txt - is OK
> http://www.eset.com




________ Information from NOD32 ________
This message was checked by NOD32 Antivirus System for Linux Mail Servers.
  part000.txt - is OK
http://www.eset.com



More information about the clean-list mailing list