<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16705" name=GENERATOR></HEAD>
<BODY>
<DIV><SPAN class=592023704-02102008><FONT face=Arial size=2>Hi
Guys,</FONT></SPAN></DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial size=2>I'm new to Haskell
and I was wondering if you can help me:</FONT></SPAN></DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial size=2>One of the first
program's I tend to write when I'm looking at a new language is a program to
generate a list of perfect numbers:</FONT></SPAN></DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial size=2>--My First Perfect
Number Generator<BR>factors :: Integer -> [Integer]<BR>factors x = [z | z
<- [1..x-1], x `mod` z == 0]</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial size=2>is_perfect ::
Integer -> Bool<BR>is_perfect x = if sum(factors x) == x then True else
False</FONT></SPAN></DIV>
<DIV> </DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial size=2>do_perfect ::
[Integer] -> [Integer]<BR>do_perfect x = [z |z <- x, is_perfect z
]</FONT></SPAN></DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial size=2>Then to run
it:</FONT></SPAN></DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial size=2>> do_perfect
[1..9000]</FONT></SPAN></DIV>
<DIV><SPAN class=592023704-02102008><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=592023704-02102008>I'm using GHC to run
it. My problem / question is this: It's running quite a lot slower than
equivalent programs in erlang and python. I suspect it's down to the way I've
written it. Any thoughts (or comments in general)</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=592023704-02102008></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=592023704-02102008>Many
thanks</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=592023704-02102008></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN
class=592023704-02102008>Matt</SPAN></FONT></DIV>
<BR>
______________________________________________________________________<BR>
This email may contain privileged or confidential information, which should only be used for the purpose for which it was sent by Xyratex. No further rights or licenses are granted to use such information. If you are not the intended recipient of this message, please notify the sender by return and delete it. You may not use, copy, disclose or rely on the information contained in it.<BR>
<BR>
Internet email is susceptible to data corruption, interception and unauthorised amendment for which Xyratex does not accept liability. While we have taken reasonable precautions to ensure that this email is free of viruses, Xyratex does not accept liability for the presence of any computer viruses in this email, nor for any losses caused as a result of viruses.<BR>
<BR>
Xyratex Technology Limited (03134912), Registered in England & Wales, Registered Office, Langstone Road, Havant, Hampshire, PO9 1SA.<BR>
<BR>
The Xyratex group of companies also includes, Xyratex Ltd, registered in Bermuda, Xyratex International Inc, registered in California, Xyratex (Malaysia) Sdn Bhd registered in Malaysia, Xyratex Technology (Wuxi) Co Ltd registered in The People's Republic of China and Xyratex Japan Limited registered in Japan.<BR>
______________________________________________________________________<BR>
</BODY></HTML>