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

Um...

    (filter #(> x 10) seq)
sure is readable for me, and I'm fluent in Python and various Lisps. (That example is Clojure.)

I would like to point out, however, that CL allows you to write:

    (loop for x in seq
          when (> x 10)
          collect x)
which you might think is verbose ("why do I need that 'collect'?")... except that loop allows you to write things like

    (loop for i in *random*
          counting (evenp i) into evens
          counting (oddp i) into odds
          summing i into total
          maximizing i into max
          minimizing i into min
          finally (return (list min max total evens odds)))
Loop knocks Python's trivial list comprehensions into a cocked hat.

I switch between map/filter and loop depending on whether I'm working with predefined functions (e.g., (filter 'less-than-ten seq)), handling multiple sequences, doing side-effects, etc.



>Loop knocks Python's trivial list comprehensions into a cocked hat.

CL could really use something like Python's generators though. The loop macro is an ugly hack in comparison.




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

Search: