[Haskell-cafe] Rewriting ord (revisited)
prstanley at ntlworld.com
Sun Sep 30 07:36:55 EDT 2007
The second version looks very neat, certainly, though I am not
entirely convinced that it's any more efficient. Still, I may be
The compiler must be one hell of a machine. I wonder if the source
code is available to the public.
At 12:26 30/09/2007, you wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>I would think that the compiler is smart enough to fuse the two loops.
>That doesn't explain the performance difference though.
>PR Stanley schrieb:
> > Hi
> > This was my original version plus some modifications as advised by the
> > list:
> > f c = sum [1 | x <- ['\0'..], x < c]
> > The following version was sent by a list member:
> > f c = length $ takeWhile (<c) ['\0'..]
> > Now, the sender asserted that the first version was much too slow. I'm
> > wondering how the second version is any more efficient than the first.
> > Looking at them through my C programmers' eye, as it were, both would
> > require at least two loops before returning the ANSI value.
> > Any ideas?
> > Thanks, Paul
> > _______________________________________________
> > Haskell-Cafe mailing list
> > Haskell-Cafe at haskell.org
> > http://www.haskell.org/mailman/listinfo/haskell-cafe
>-----BEGIN PGP SIGNATURE-----
>Version: GnuPG v1.4.7 (MingW32)
>Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
>-----END PGP SIGNATURE-----
More information about the Haskell-Cafe