Re: [Haskell-cafe] Fusion for fun and profi (Was: newbie optimization question)

2007-10-29 Thread Isaac Dupree
Don Stewart wrote: default(Int) divisors i = filter (\j -> i `rem`j == 0) (enumFromTo 1 (i-1)) main = print $ filter (\i -> i == sum (divisors i)) (enumFromTo 1 1) ... So almost identical types to the C program (bar for the return [Int]). Finally, we can manually

Re: [Haskell-cafe] Fusion for fun and profi (Was: newbie optimization question)

2007-10-28 Thread Don Stewart
dons: > stefanor: > > On Sun, Oct 28, 2007 at 01:25:19PM -0700, Don Stewart wrote: > > > Finally, we can manually translate the C code into a confusing set of > > > nested > > > loops with interleaved IO, > > > > > > main = loop 1 > > > where > > > loop !i | i > 1 = return

Re: [Haskell-cafe] Fusion for fun and profi (Was: newbie optimization question)

2007-10-28 Thread Tim Chevalier
On 10/28/07, Stefan O'Rear <[EMAIL PROTECTED]> wrote: > On Sun, Oct 28, 2007 at 01:43:07PM -0700, Don Stewart wrote: > > stefanor: > > > IO blocks unboxing in GHC. How fast is your mock-C code refactored to > > > do IO outside of the loops only? > > > > It doesn't! The above code yields: > > > >

Re: [Haskell-cafe] Fusion for fun and profi (Was: newbie optimization question)

2007-10-28 Thread Stefan O'Rear
On Sun, Oct 28, 2007 at 01:43:07PM -0700, Don Stewart wrote: > stefanor: > > IO blocks unboxing in GHC. How fast is your mock-C code refactored to > > do IO outside of the loops only? > > It doesn't! The above code yields: > > Main.$wloop :: GHC.Prim.Int# >-> GHC.Prim.Sta

Re: [Haskell-cafe] Fusion for fun and profi (Was: newbie optimization question)

2007-10-28 Thread Don Stewart
stefanor: > On Sun, Oct 28, 2007 at 01:25:19PM -0700, Don Stewart wrote: > > Finally, we can manually translate the C code into a confusing set of nested > > loops with interleaved IO, > > > > main = loop 1 > > where > > loop !i | i > 1 = return () > > | othe

Re: [Haskell-cafe] Fusion for fun and profi (Was: newbie optimization question)

2007-10-28 Thread Stefan O'Rear
On Sun, Oct 28, 2007 at 01:25:19PM -0700, Don Stewart wrote: > Finally, we can manually translate the C code into a confusing set of nested > loops with interleaved IO, > > main = loop 1 > where > loop !i | i > 1 = return () > | otherwise = if i == go i 0 1 t

[Haskell-cafe] Fusion for fun and profi (Was: newbie optimization question)

2007-10-28 Thread Don Stewart
rendel: > Prabhakar Ragde wrote: > >divisors i = [j | j<-[1..i-1], i `mod` j == 0] > >main = print [i | i<-[1..1], i == sum (divisors i)] > > Jerzy Karczmarczuk wrote: > >My point didn't concern that point. Haskell compiler cannot change an > >algorithm using lists into something which deals w