[Haskell-cafe] Re: FASTER primes

Will Ness will_n48 at yahoo.com
Mon Jan 4 13:25:24 EST 2010


Emil Axelsson <emax <at> chalmers.se> writes:

> 
> > For me, a real smart compiler is one that would take in e.g. (sum $ 
> > take n $ 
> > cycle $ [1..m]) and spill out a straight up math formula, inside a few ifs 
> > maybe (just an aside). 
> 
> (Also an aside, I couldn't resist...)
> 
> Then I'm sure you'd say that Feldspar [1] has a smart compiler :)


but it didn't produce

f n m = if n < m then n*(n+1)/2 else
        let (q,r)=quotRem n m
        in q*(m*(m+1)/2) + r*(r+1)/2

:)

 
> The above expression written in Feldspar and the resulting C code can be 
> found here:
> 
>    http://hpaste.org/fastcgi/hpaste.fcgi/view?id=15592#a15593
> 
> 
> / Emil
> 
> [1] http://feldspar.sourceforge.net/
> 






More information about the Haskell-Cafe mailing list