Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

    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


Yes. 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.




Consider applying for YC's Summer 2026 batch! Applications are open till May 4

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: