Re:Why Learning Haskell/Python Makes You a Worse Programmer
by d0mine on Tuesday December 23, 2008 @03:13PM
(#408030)
Perl:
Or
Ruby:
Python:
Or if we'd like to constrain ourselves to one method `FooClass.description()`
Or if you don't like `filter()`
Or if `description()` is a side-effect-free method then It should be a property:
At the end of the day new features doesn't matter due to most .NET-shops use old C# versions and It will not change any time soon.
[ Parent
| on HN ]
Re:Why Learning Haskell/Python Makes You a Worse Programmer
by euccastro on Tuesday December 23, 2008 @08:19PM
(#408335)
# `None` means `lambda x: x` here
I find it more helpful to think of it as meaning `bool` in that context. I think the None special case is only there because filter() predates bool() in Python.
Re:Why Learning Haskell/Python Makes You a Worse Programmer
by d0mine on Tuesday December 23, 2008 @08:37PM
(#408365)
Thanks. `bool` is more readable.
"\n".join(filter(bool, descriptions))
Or `len` "\n".join(filter(len, descriptions))
Re:Why Learning Haskell/Python Makes You a Worse Programmer
by bprater on Tuesday December 23, 2008 @03:32PM
(#408064)
Which seems the most "readable"? I think the Ruby one might be.
Re:Why Learning Haskell/Python Makes You a Worse Programmer
by DaniFong on Tuesday December 23, 2008 @06:31PM
(#408210)
I like the python version: it is the densest, and most similar to set notation. It is done similarly in Fortress.
Re:Why Learning Haskell/Python Makes You a Worse Programmer
by d0mine on Tuesday December 23, 2008 @03:51PM
(#408088)
I like the Ruby one most. But "readable" is matter of taste (or programmer's background: I consider
while (*to++ = *from++);
to be a readable C code (not that I'll recommend it)).It is wrong to judge a language by tiniest code examples.
Re:Why Learning Haskell/Python Makes You a Worse Programmer
by hassy on Tuesday December 23, 2008 @06:24PM
(#408206)
How about this?
myList collect(description) select(!="") join("\n")
http://www.iolanguage.com/scm/git/checkout/Io/docs/IoGuide.h...
Re:Why Learning Haskell/Python Makes You a Worse Programmer
by lsb on Wednesday December 24, 2008 @12:29PM
(#408965)
Using Symbol#to_proc, the old Ruby
myList.collect { |f| f.description }.select { |d| d != "" }.join("\n")
becomes myList.map(&:description).reject(&:empty?).join("\n")
which is even more direct: take my list, map each element to its description, reject anything empty, and join with newlines.
Re:Why Learning Haskell/Python Makes You a Worse Programmer
by d0mine on Wednesday December 24, 2008 @06:21PM
(#409230)
I thought `Symbol#to_proc` is a Rails' extension.
Re:Why Learning Haskell/Python Makes You a Worse Programmer
by lsb on Wednesday December 24, 2008 @11:38PM
(#409409)
I learned about it in 2005, when I read it on http://pragdave.pragprog.com/pragdave/2005/11/symbolto_proc.... and it's such a good idea that they've folded it into 1.9 http://www.infoq.com/news/2008/02/to_proc-currying-ruby19