Re: [Haskell-cafe] haskell in online contests

2009-11-29 Thread Daniel Fischer
Am Samstag 28 November 2009 21:21:20 schrieb vishnu: > this is where I've gotten to. > http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=5120#a5120 > strangely enough Ive gotten no speedup at all from the substitution cost > UArray (though I had to make it Int, Int to deal with digits.). Converting

Re: [Haskell-cafe] haskell in online contests

2009-11-28 Thread wren ng thornton
vishnu wrote: wow ok, I'm not even able to see why they're different in the desugared version They're different because case is strict binding (see caveat below) whereas let is lazy binding. If we say, let foo = big ugly computation in bar Then if foo isn't used in bar, it'll never be c

Re: [Haskell-cafe] haskell in online contests

2009-11-28 Thread wren ng thornton
vishnu wrote: I always thought lazyness was automatic and seq made strictness possible. Laziness is the default, but that doesn't mean it's everywhere. For example, every time you do pattern matching you enforce strictness: foo (x:xs) = 5 ==> foo _|_ == _|_ However, there's also

Re: [Haskell-cafe] haskell in online contests

2009-11-28 Thread vishnu
this is where I've gotten to. http://moonpatio.com/fastcgi/hpaste.fcgi/view?id=5120#a5120 strangely enough Ive gotten no speedup at all from the substitution cost UArray (though I had to make it Int, Int to deal with digits.). But still I wonder if there's something else I missed. Im really curious

Re: Re[2]: [Haskell-cafe] haskell in online contests

2009-11-27 Thread Luke Palmer
On Fri, Nov 27, 2009 at 9:18 PM, vishnu wrote: > Hi Bulat >    hmm ok I understand the issue of compiler maturity. But I thought > lazyness was meant to be a bonus? Or is it that if you really try to squeeze > performance it becomes more of a hindrance? One of my favorite quotes by Heinrich Apfel

Re: Re[2]: [Haskell-cafe] haskell in online contests

2009-11-27 Thread Brandon S. Allbery KF8NH
On Nov 27, 2009, at 23:18 , vishnu wrote: hmm ok I understand the issue of compiler maturity. But I thought lazyness was meant to be a bonus? Or is it that if you really try to squeeze performance it becomes more of a hindrance? If you're trying to eke out every last bit of performance,

Re: Re[2]: [Haskell-cafe] haskell in online contests

2009-11-27 Thread vishnu
Hi Bulat hmm ok I understand the issue of compiler maturity. But I thought lazyness was meant to be a bonus? Or is it that if you really try to squeeze performance it becomes more of a hindrance? On Sat, Nov 28, 2009 at 1:47 AM, Bulat Ziganshin wrote: > Hello Don, > > Friday, November 27, 2009,

Re: [Haskell-cafe] haskell in online contests

2009-11-27 Thread vishnu
Hi Daniel Wow that's fantastic. Could you explain those further optimisations a bit more please? Especially the whole "more lazyness" thing. Timings here: Your last ByteString code: 128s That with corrected index calculation: 172s Correct indices and distance orig new = f m n instead of memf m

Re: [Haskell-cafe] haskell in online contests

2009-11-27 Thread vishnu
wow I just woke up to see this :). Im impressed at the speed of the response, thanks Daniel Bad news first. > a) According to codechef, you must also consider digits. > you're right, I totally missed this. Thanks :) b) Your distance function is wrong. > > With idx i j = (i+1)*(j+1) - 1, you w

Re: [Haskell-cafe] haskell in online contests

2009-11-27 Thread Daniel Fischer
Am Samstag 28 November 2009 02:04:31 schrieb Daniel Fischer: > Make it > > distance orig new = f m n > > and no thunks need be written at all in this case. > Cuts down running time by nearly half :) > > I think you could speed it up significantly by calculating the distance > more lazily. Yup :D

Re: [Haskell-cafe] haskell in online contests

2009-11-27 Thread Daniel Fischer
Am Freitag 27 November 2009 20:41:37 schrieb vishnu: > Ive just started learning haskell pretty recently and Ive been trying to > solve some online contest problems as part of this exercise. However, Ive > been having almost no success. For various reasons my answers almost always > are too slow. I

Re[2]: [Haskell-cafe] haskell in online contests

2009-11-27 Thread Bulat Ziganshin
Hello Don, Friday, November 27, 2009, 11:08:44 PM, you wrote: >> it's just false assumption that you should got speed comparable to >> other languages. haskell is lazy and ghc has much less mature compiler > "comparable to other languages" eh? > That seems a little too broad to be meaningful, Bu

Re: [Haskell-cafe] haskell in online contests

2009-11-27 Thread Don Stewart
bulat.ziganshin: > Hello vishnu, > > Friday, November 27, 2009, 10:41:37 PM, you wrote: > > it's just false assumption that you should got speed comparable to > other languages. haskell is lazy and ghc has much less mature compiler "comparable to other languages" eh? That seems a little too bro

Re: [Haskell-cafe] haskell in online contests

2009-11-27 Thread Bulat Ziganshin
Hello vishnu, Friday, November 27, 2009, 10:41:37 PM, you wrote: it's just false assumption that you should got speed comparable to other languages. haskell is lazy and ghc has much less mature compiler > Ive just started learning haskell pretty recently and Ive been > trying to solve some onli

[Haskell-cafe] haskell in online contests

2009-11-27 Thread vishnu
Ive just started learning haskell pretty recently and Ive been trying to solve some online contest problems as part of this exercise. However, Ive been having almost no success. For various reasons my answers almost always are too slow. I recently stumbled across this link which was quite useful ht