As others have pointed out, there are many allowed evaluation orders of this expressions.<br>But not only that, how it gets evaluated depends on how you are going to use it. Say that you print it, then you need all 4 elements, but say that it's oly going to be used as an argument to null, then you will evaluate less (probably).<br>
<br>Even so, it's instructive to study how the normal order reduction of this expression would proceed under the assumption that all 4 elements will be used.<br><br> -- Lennart<br><br><div class="gmail_quote">On Fri, May 9, 2008 at 6:52 PM, PR Stanley <<a href="mailto:prstanley@ntlworld.com">prstanley@ntlworld.com</a>> wrote:<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>
(take 4 . map (>0)) (f s t)<br>
where<br>
s = 2 : t<br>
t = 3 : s<br>
f = zipWith (-)<br>
What would be the order of evaluation for the above code? How would I illustrate the evaluation step-by-step?<br>
I'm guessing that the code necessitates lazy evaluation and as such it starts with take then it applies f which in turn applies s and t and zipWith until the first element satisfies the predicate in map and This is repeated 4 times<br>
What does the list think?<br>
Many thanks,<br>
Paul<br>
P.S. I'm not done with induction. I'm just letting it rst for a bit.<br>
<br>
_______________________________________________<br>
Haskell-Cafe mailing list<br>
<a href="mailto:Haskell-Cafe@haskell.org" target="_blank">Haskell-Cafe@haskell.org</a><br>
<a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank">http://www.haskell.org/mailman/listinfo/haskell-cafe</a><br>
</blockquote></div><br>