4 ms·
One thing I love about Lisp is that it's ridiculously easy to write (cons item some-list), or even (cons item1 (cons item2 some-list)). Iterators can h
by rbonvall 14y ago
One thing I love about Lisp is that it's
ridiculously easy to write (cons item some-list),
or even (cons item1 (cons item2 some-list)).
Iterators can help (and in O(1)):
>>> from itertools import chain
>>> some_list = range(5)
>>> item = 99
>>> a = chain([item], some_list)
>>> for x in a:
... print x
...
99
0
1
2
3
4
- gbog 14y agoYes. That's the hole point of the article, and matches very well with my understanding of SICP: functional programming is possible only if you model changing state in streams, which are just called iterators in python. All the fuss about python missing some parts too be really functional seem to have missed the point to me.