<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">OK, in f, *length* already knows it's argument is a list.<br><br>In g, *length* doesn't know what's inside the parens, extra evaluation there. So g is already ahead before we get to what's inside the [] and ().<br><br>But since both still have eval x to *thunk* : *thunk*, g evaluates "to a deeper level?"<br><br>Michael<br><br><br>> Wouldn't both functions need to evaluate x to the same level, *thunk* : *thunk* to insure listhood?<br>><br>> f x = length [head *thunk* : *thunk*]<br>> g x = length (tail *thunk* : *thunk*)<br>><br>> Michael<br>><br>><br>> _______________________________________________<br>> Haskell-Cafe mailing list<br>> <a ymailto="mailto:Haskell-Cafe@haskell.org" href="http://us.mc311.mail.yahoo.com/mc/compose?to=Haskell-Cafe@haskell.org"><span class="yshortcuts"
id="lw_1280594505_1">Haskell-Cafe@haskell.org</span></a><br>> <a href="http://www.haskell.org/mailman/listinfo/haskell-cafe" target="_blank"><span class="yshortcuts" id="lw_1280594505_2">http://www.haskell.org/mailman/listinfo/haskell-cafe</span></a><br>><br><br>Notice the two different kinds of brackets being used in f versus g :)<br><br>--- On <b>Sat, 7/31/10, Ben Millwood <i><haskell@benmachine.co.uk></i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Ben Millwood <haskell@benmachine.co.uk><br>Subject: Re: [Haskell-cafe] Laziness question<br>To: "michael rice" <nowgate@yahoo.com><br>Cc: haskell-cafe@haskell.org<br>Date: Saturday, July 31, 2010, 12:38 PM<br><br><div class="plainMail">On Sat, Jul 31, 2010 at 4:56 PM, michael rice <<a ymailto="mailto:nowgate@yahoo.com" href="/mc/compose?to=nowgate@yahoo.com">nowgate@yahoo.com</a>>
wrote:<br>><br>> From: <a href="http://en.wikibooks.org/wiki/Haskell/Laziness" target="_blank">http://en.wikibooks.org/wiki/Haskell/Laziness</a><br>><br>><br>> Given two functions of one parameter, f and g, we say f is stricter than g if f x evaluates x to a deeper level than g x<br>><br>> Exercises<br>><br>> 1. Which is the stricter function?<br>><br>> f x = length [head x]<br>> g x = length (tail x)<br>><br>><br>><br>> Prelude> let f x = length [head x]<br>> Prelude> let g x = length (tail x)<br>> Prelude> f undefined<br>> 1<br>> Prelude> g undefined<br>> *** Exception: Prelude.undefined<br>> Prelude><br>><br>><br>><br>> So, g is stricter than f?<br>><br>> Wouldn't both functions need to evaluate x to the same level, *thunk* : *thunk* to insure listhood?<br>><br>> f x = length [head *thunk* : *thunk*]<br>> g x = length (tail *thunk*
: *thunk*)<br>><br>> Michael<br>><br>><br>> _______________________________________________<br>> Haskell-Cafe mailing list<br>> <a ymailto="mailto:Haskell-Cafe@haskell.org" href="/mc/compose?to=Haskell-Cafe@haskell.org">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>><br><br>Notice the two different kinds of brackets being used in f versus g :)<br></div></blockquote></td></tr></table><br>