<br><br>On Sun, Jun 6, 2010 at 5:10 AM, Thomas Hartman <<a href="mailto:tphyahoo@gmail.com">tphyahoo@gmail.com</a>> wrote:<br>> Here's two implementations of break, a snappy one from the prelude,<br>...<br>> prelbreak p xs = (takeWhile (not . p) xs,dropWhile (not . p) xs) --<br>
> fast, more or less as implemented in prelude iiuc<br><br>I had a look at the prelude, and I was surprised to see there's 2 versions, depending on a flag :<br><br><blockquote class="webkit-indent-blockquote" style="margin: 0 0 0 40px; border: none; padding: 0px;">
<font class="Apple-style-span" face="'courier new', monospace">#ifdef USE_REPORT_PRELUDE<br></font><font class="Apple-style-span" face="'courier new', monospace">break p = span (not . p)<br>
</font><font class="Apple-style-span" face="'courier new', monospace">#else<br></font><font class="Apple-style-span" face="'courier new', monospace">-- HBC version (stolen)<br></font><font class="Apple-style-span" face="'courier new', monospace">break _ xs@[] = (xs, xs)<br>
</font><font class="Apple-style-span" face="'courier new', monospace">break p xs@(x:xs')<br></font><font class="Apple-style-span" face="'courier new', monospace"> | p x = ([],xs)<br></font><font class="Apple-style-span" face="'courier new', monospace"> | otherwise = let (ys,zs) = break p xs' in (x:ys,zs)<br>
</font><font class="Apple-style-span" face="'courier new', monospace">#endif</font></blockquote><div><br></div><div>I'm curious why is it so, and which version is compiled in the platform or the ghc binaries.</div>
<div>( my guess is USE_REPORT_PRELUDE compiles functions as defined in the haskell report, but the other version is faster and used by default. )</div><br>David.