[Haskell-cafe] Rewriting ord (revisited)

PR Stanley 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 
missing something.
The compiler must be one hell of a machine. I wonder if the source 
code is available to the public.
Cheers, Paul
At 12:26 30/09/2007, you wrote:
>-----BEGIN PGP SIGNED MESSAGE-----
>Hash: RIPEMD160
>
>I would think that the compiler is smart enough to fuse the two loops.
>That doesn't explain the performance difference though.
>
>Adrian
>
>
>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
>
>iD8DBQFG/4f+11V8mqIQMRsRAxegAJ4t5grdRDrWVWby6tjDZDdxgJ72FQCfcD7W
>Mntl7FV2GpCGtpY2yP61kbk=
>=l+3X
>-----END PGP SIGNATURE-----



More information about the Haskell-Cafe mailing list