Print

Print


Thanks, Andrew.  Very cool article.

  Lazy evaluation is definitely one of those amazingly cool subjects
  that most CS students miss out on due to the language and paradigm
  choices of our departments.  Purely functional languages like
  Haskell have laziness built in, and you can get the effect pretty
  easily in either OCaml or Lisp with a little ingenuity.  OCaml does
  it with lazy thunks
  (http://enfranchisedmind.com/blog/2007/01/01/ocaml-lazy-lists-an-introduction/),
  and in Lisp you can pull it off with a couple of macros and a bit of
  function overloading.  You just have to capture the evaluation of
  infinite series in closures using lambda forms and then evaluate
  them on demand.  This is IMHO absolutely fucking brilliant.

  I've attached a code example which creates lazy lists in Common Lisp
  and shows them off with a function (primes) which computes all the
  prime numbers.  Yes, ALL of them.  Enjoy.