[clean-list] Re: stupid question
Carlos Aya
carlosayam at yahoo.com.au
Tue Dec 11 23:44:28 MET 2007
Hello,
There are no stupid questions when one is a newbie, like me ;-)
I think you want
isum :: Int -> Int
isum x
| x<10 = x
| otherwise = isum ((isum (x / 10)) + (x rem 10))
Instead of "ones" I used "rem" (imported via StdEnv -> StdInt)
And the recursion step is, first over x/10 and then adding that to the remainder, which is the last digit, and recursing again.
BTW, is there a public wiki for Clean development around?
regards
Carlos
----- Original Message ----
From: "clean-list-request at science.ru.nl" <clean-list-request at science.ru.nl>
To: clean-list at science.ru.nl
Sent: Tuesday, 11 December, 2007 10:00:10 PM
Subject: clean-list Digest, Vol 37, Issue 7
Send clean-list mailing list submissions to
clean-list at science.ru.nl
To subscribe or unsubscribe via the World Wide Web, visit
http://mailman.science.ru.nl/mailman/listinfo/clean-list
or, via email, send a message with subject or body 'help' to
clean-list-request at science.ru.nl
You can reach the person managing the list at
clean-list-owner at science.ru.nl
When replying, please edit your Subject line so it is more specific
than "Re: Contents of clean-list digest..."
Today's Topics:
1. WRS 2008 - 1st Call for Papers (aart.middeldorp at uibk.ac.at)
2. stupid question (David Minor)
3. Re: stupid question (Cristian Baboi)
4. RE: stupid question (David Minor)
----------------------------------------------------------------------
Message: 1
Date: Mon, 10 Dec 2007 11:58:13 GMT
From: aart.middeldorp at uibk.ac.at
Subject: [clean-list] WRS 2008 - 1st Call for Papers
To: clean-list at cs.kun.nl
Message-ID: <200712101158.lBABwDXH003977 at pc080-c703.uibk.ac.at>
1st Call for Papers
**********
W R S 2008
**********
http://cl-informatik.uibk.ac.at/events/wrs08/
8th International Workshop on Reduction Strategies in Rewriting and
Programming
July 14, 2008, Castle of Hagenberg, Austria
Important Dates
---------------
Title & abstract: April 21, 2008
Paper submission: April 28, 2008
Notification: May 26, 2008
Final version: June 16, 2008
Background
----------
The workshop promotes and stimulates research and collaboration in the
area of strategies. It encourages the presentation of new directions,
developments, and results as well as surveys and tutorials on existing
knowledge in this area. WRS 2008 collocates with RTA 2008, the 19th
International Conference on Rewriting Techniques and Applications. For
more information, consult the WRS 2008 website.
Topics
------
Topics of interest include, but are not restricted to:
* foundations for the definition and semantic description of reduction
strategies
* strategies in rewriting, lambda calculi, narrowing, constraint
solving
* strategies in programming languages
* strategies and tactics in theorem and termination proving
* properties of strategies and corresponding computations
* interrelations, combinations and applications of computation under
different
evaluation strategies
* analysis and optimization techniques for reduction strategies
* rewrite systems, tools and implementations with flexible strategies
* strategies suitable to software engineering problems and applications
* tutorials and systems related to strategies
Program Committee
-----------------
* Elvira Albert (Madrid)
* Gabrielle Keller (Sydney)
* Helene Kirchner (Nancy)
* Temur Kutsia (Linz)
* Ian Mackie (Paris)
* Aart Middeldorp (Innsbruck) chair
* Pierre-Etienne Moreau (Nancy)
* Michael Norrish (Canberra)
* Femke van Raamsdonk (Amsterdam)
* Kristoffer Rose (Yorktown Heights)
* Amr Sabry (Bloomington)
* Masahiko Sakai (Nagoya)
Submission
----------
There are two categories of submissions:
(A) Submissions to the formal proceedings
These submissions must describe unpublished work. Accepted
submissions
of this category will be published both in the informal and in the
formal proceedings. The formal proceedings will be published after
the
workshop by Elsevier as a volume of ENTCS.
(B) Submissions to the informal proceedings
These submissions may also describe work that has been or will be
submitted or published elsewhere or work in progress. Accepted
submissions of this category will be published in the informal
proceedings, which will be distributed during the workshop.
The page limit for papers in both categories is 15 pages in ENTCS
style.
We also explicitly solicit survey and tutorial submissions (of either
category) which may be longer. The necessary style files and
instructions
can be found at http://www.entcs.org/prelim.html. The submission page
for
WRS 2008 is
http://www.easychair.org/conferences/?conf=WRS2008
------------------------------
Message: 2
Date: Tue, 11 Dec 2007 10:46:45 +0200
From: "David Minor" <david-m at orbotech.com>
Subject: [clean-list] stupid question
To: <clean-list at science.ru.nl>
Message-ID: <FCB44A2146B78C479695CF9CCA7EEA8702C2D1B5 at excg-isl01>
Content-Type: text/plain; charset="us-ascii"
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-0001.html
------------------------------
Message: 3
Date: Tue, 11 Dec 2007 11:00:05 +0200
From: "Cristian Baboi" <cristi at ot.onrc.ro>
Subject: Re: [clean-list] stupid question
To: "David Minor" <david-m at orbotech.com>
Cc: clean-list at science.ru.nl
Message-ID: <op.t25xyfl7h3znim at pccristi.ot.onrc.ro>
Content-Type: text/plain; format=flowed; delsp=yes; charset=utf-8
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
------------------------------
Message: 4
Date: Tue, 11 Dec 2007 11:05:32 +0200
From: "David Minor" <david-m at orbotech.com>
Subject: RE: [clean-list] stupid question
To: "Cristian Baboi" <cristi at ot.onrc.ro>
Cc: clean-list at science.ru.nl
Message-ID: <FCB44A2146B78C479695CF9CCA7EEA8702C2D1BD at excg-isl01>
Content-Type: text/plain; charset="UTF-8"
I expected it to recurse on isum until x<10, that is isum 999 should
equal 9, why does it terminate at 27?
-----Original Message-----
From: Cristian Baboi [mailto:cristi at ot.onrc.ro]
Sent: Tuesday, December 11, 2007 11:00 AM
To: David Minor
Cc: clean-list at science.ru.nl
Subject: Re: [clean-list] stupid question
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
------------------------------
_______________________________________________
clean-list mailing list
clean-list at science.ru.nl
http://mailman.science.ru.nl/mailman/listinfo/clean-list
End of clean-list Digest, Vol 37, Issue 7
*****************************************
Make the switch to the world's best email. Get the new Yahoo!7 Mail now. www.yahoo7.com.au/worldsbestemail
More information about the clean-list
mailing list