News for hackers. Stuff that matters.
Re:Why Clojure? by rdtsc on Thursday August 19, 2010 @12:27AM (#1616511)
It is also very easy in Python:

Use generator list comprehensions:

    (x for x in xs)
instead of building the full list:

    [x for x in xs]
Use generators instead of plain functions when you can.

Learn to use itertools module: http://docs.python.org/library/itertools.html

I use these often:

    * chain()
    * imap()
    * groupby()
    * takewhile()
    * tee()
    * izip()
    * izip_longest()
    * permutations()
You can make you code quite "lazy" if you practice enough, and eventually it just becomes a habit. Whenever you do anything you start asking yourself : "can I do this in a lazy way?"
Re:Why Clojure? by weavejester on Thursday August 19, 2010 @07:47PM (#1619054)
Iterators in Python are slightly different from lazy lists in languages like Haskell and Clojure. In Python, iterators are stateful; calling next() moves the iterator on, discarding the previous head. In Clojure, a seq has no state, and the head is not automatically discarded when the next item is accessed.