Hi,<br><br>Thank you all for you replies.<br><br>I think now I understand Haskell better.<br><br>Best regards,<br>Frodo<br><br><div class="gmail_quote">2011/10/12 Frodo Chao <span dir="ltr"><<a href="mailto:frodogreat@gmail.com">frodogreat@gmail.com</a>></span><br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">Hi,<br><br>I came upon this when playing with foldr and filter. Compare the two definitions:<br>
<br>testr n = foldr (\x y -> x && y) True [t | (_, t) <- zip [1 .. n] [True, True ..]]<br>testr' n = foldr (\x y -> y && x) True [t | (_, t) <- zip [1 .. n] [True, True ..]]<br>
<br>I tried these functions on ghci (The Glorious Glasgow Haskell Compilation System, version 7.0.3), and get the following results (with :set +s):<br><br>testr 1000000 => True<br>(0.01 secs, 7920832 bytes)<br>testr' 1000000 => True<br>
(8.72 secs, 446585344 bytes)<br><br>This bizarre (at least to me) behavior also applies to ||. Should I mind the orderings of the parameters (especially the accumulator) in the function passed to foldr?<br><br>Thak you for reading.<br>
<br>Sincerely yours,<br><font color="#888888">Frodo Chao<br><br>
</font></blockquote></div><br>