by djacobs · 16y ago · 0 comments
I wasn't saying that is how I would implement filters. Just that that is the DRYest way to do so--and it's easy in Ruby.
I'm not looking to second guess each of your examples, many of which were fine. I felt that your currying example was trying to bring in a purely functional toolkit ala Lisp when it wasn't appropriate. Function composition (which you allude to in your reply, yet I don't see) and blocks (especially!) show off Ruby's functional capabilities quite well and would be just as effective and more practical.
Btw, if you're quite new to Python, do yourself a favor and learn about list comprehensions. They can be quite wonderful.
Good luck!
As I say, I wouldn't use that last technique in my actual code. It just shows how powerful the language actually is. I think my normal code falls in line with the standard Ruby paradigms, but with a functional twist.
And yes, list comprehensions are fantastic. :)