On Tuesday 08 June 2010 08:33:51, David Virebayre wrote: > On Sun, Jun 6, 2010 at 5:10 AM, Thomas Hartman <tphya...@gmail.com> wrote: > > Here's two implementations of break, a snappy one from the prelude, > > ... > > > prelbreak p xs = (takeWhile (not . p) xs,dropWhile (not . p) xs) -- > > fast, more or less as implemented in prelude iiuc > > I had a look at the prelude, and I was surprised to see there's 2 > versions, depending on a flag : > > #ifdef USE_REPORT_PRELUDE > break p = span (not . p) > #else > -- HBC version (stolen) > break _ x...@[] = (xs, xs) > break p xs@(x:xs') > > | p x = ([],xs) > | otherwise = let (ys,zs) = break p xs' in (x:ys,zs) > > #endif > > > I'm curious why is it so, and which version is compiled in the platform > or the ghc binaries. > ( my guess is USE_REPORT_PRELUDE compiles functions as defined in the > haskell report, but the other version is faster and used by default. )
Aye. I'm not sure whether there's a difference with -O2, but it's substantial without optimisations. > > David. _______________________________________________ Haskell-Cafe mailing list Haskell-Cafe@haskell.org http://www.haskell.org/mailman/listinfo/haskell-cafe