[Haskell-cafe] Laziness question

Brandon S Allbery KF8NH allbery at ece.cmu.edu
Sat Jul 31 14:29:50 EDT 2010


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 7/31/10 14:24 , michael rice wrote:
> Are you saying:
> 
> [ head x ]  ->  [ *thunk* ]   and   length [ *thunk* ] ->  1, independent of
> what *thunk* is, even head [], i.e., *thunk* never needs be evaluated?

Exactly.  (I was being cagey because the first response was cagey, possibly
suspecting a homework question although it seems like an odd time for it.)

length not only does not look inside of the thunk, it *can't* look inside
it; all it knows is that it has a list, it specifically does *not* know what
that list can hold.  So the only thing it can do is count the number of
"unknown somethings" in the list.

- -- 
brandon s. allbery     [linux,solaris,freebsd,perl]      allbery at kf8nh.com
system administrator  [openafs,heimdal,too many hats]  allbery at ece.cmu.edu
electrical and computer engineering, carnegie mellon university      KF8NH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.10 (Darwin)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAkxUa54ACgkQIn7hlCsL25XVpgCeIxWwVWhjYQQ86uE2JeJD7mCB
mKUAn3WwhrgrYyudv/E8pn5a0HB4gLA9
=H++/
-----END PGP SIGNATURE-----


More information about the Haskell-Cafe mailing list