3 ms·
To be honest that Python list comprehension is really hard for me to internalize. I find Ruby way much more natural. xx.select { |x| bar(x) } Even Clojure is
by drmrkela 14y ago
To be honest that Python list comprehension is really hard for me to internalize.
I find Ruby way much more natural.
xx.select { |x| bar(x) }
Even Clojure is better
(filter (fn[x](bar x)) xx)
or
(filter #(bar %) xx)
- osener 14y agoYou don't need that anonymous function in Clojure, (filter bar xx) is enough just like Haskell.
- deleted 14y ago[deleted]
- drmrkela 14y agoYou are right. Thanks.
- wonderzombie 14y agoSure, I do, too. Ruby is one of the languages that made me experience how expressive the higher-order function pattern really is. That said, in Python, you have to take what you can get, though. And generally I expect more people are familiar with Python than Haskell. Probably I should've used Ruby. Oh well.
- wonderzombie 14y agoBTW, friendly tip: if you want code formatting, try using four spaces of indent. You might only need two, actually. Let's see. Two spaces: filter foo xx Four spaces: filter foo xx