[Haskell-cafe] efficient chop

Daniel Fischer daniel.is.fischer at googlemail.com
Wed Sep 14 13:19:07 CEST 2011


On Wednesday 14 September 2011, 09:17:16, Kazu Yamamoto wrote:
> You can find the results of my friend:
> 
>         https://gist.github.com/1215660
> 
> Please ignore the Japanese text. Please read the code and the results.
> I'm not sure why you had the different result.

Input size. The lazy foldr combinator gets compiled to a bigger, more 
complicated function. When the input is short, the code size makes it 
slower. But when the input is long, the lazy foldr wins because it can 
produce incremental results while the strict foldr combinator and revChop 
need to traverse the entire list before they can produce anything - except 
for the case of 'spaces', where indeed the strict foldr combinator is 
(slightly) faster.



More information about the Haskell-Cafe mailing list