Re: Hugs Crashes W2K

"ion" <[email protected]>
Newsgroups gmane.comp.lang.haskell.hugs.bugs
Message-ID <007b01c26e32$ec5419f0$04bbbc93@nonamee94lxznt>
here is the working code for comparison:

-- Checks whether or not a given Integer is prime
prime:: Integer -> Integer
prime x = if ((x==0)||(x==1)||(x==2)) then error "NUMBER IS PRIME" 
          else
             if x<0 then prime (0-(-x))
             else prime_helper x 2 

-- Used within 'prime' to determine if a number is prime or not
prime_helper:: Integer -> Integer -> Integer
prime_helper x y =
   if ((rem) x y)==0 then error "NUMBER IS NOT PRIME"
   else
      if x==(y+1) then error "NUMBER IS PRIME"
      else prime_helper x (y+1)

----- Original Message ----- 
From: "ion" <[email protected]>
To: <[email protected]>
Sent: Monday, October 07, 2002 7:32 PM
Subject: Hugs Crashes W2K


> Hug's crashes when I try to use the 'prime' function
> defined below, note that the function calls prime_helper
> and this is the likely cause of the crash, also note that
> the reason for the crash is probable error in the
> function definition. This is on Windows 2000, is there
> a fix for this (apart from, "don't use windows" ;))
> as otherwise the tool is unusable?
> 
> ion
> 
> -- Checks whether or not a given Integer is prime
> prime:: Integer -> Integer
> prime x = if x==0 then error "x = 0" 
>           else
>              if x<0 then prime (0-(-x))
>              else prime_helper x 2 
> 
> -- Used within 'prime' to determine if a number is prime or not
> prime_helper:: Integer -> Integer -> Integer
> prime_helper x y =
>    if ((rem) x y)==0 then error "NUMBER IS NOT PRIME"
>    else
>       if x==y-1 then error "NUMBER IS PRIME"
>       else prime_helper x y+1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.