
Am Montag 01 Februar 2010 10:37:41 schrieb Markus Böhm:
Daniel, Stephen, Felipe thanks for Your answers/advice, which I studied this morning. Helps me a lot on my learning curve. I guess it takes some time to get a feeling for the performance/runtime behaviour of abstractions in Haskell.
Just for fun and w/o knowing Lua: I translated my Haskell "loops-while"-version into Lua
That's not quite a translation of the loop you posted. Not really important, though, small difference.
and ran on LuaJit Beta 2.0.0. Seems to beat our best Haskell version.
So LuaJit Beta 2.0.0 beats gcc -O3 on such a simple loop? I'm not going to install Lua to test, but if that's really the case, I'm sure the folks at gnu.org would like to hear about it. Or don't you consider -fvia-C compiled loops to be true Haskell versions?
print("EPS: ") EPS = io.read("*number") pi2 = 1 i = 3 s = false repeat pi1 = pi2 if s then pi2 = pi1 + 1.0/i s = false else pi2 = pi1 - 1.0/i s = true end i = i+2
until EPS > 4.0 * math.abs(pi2-pi1)
print("PI mit EPS", EPS," = ",4*pi1," n= ",(i-3)/2)
-- Markus