[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Re: code density -- was:[ANN] GSL Shell...
- From: steve donovan <steve.j.donovan@...>
- Date: Sat, 5 Dec 2009 12:45:55 +0200
On Sat, Dec 5, 2009 at 12:30 PM, Bulat Ziganshin
<firstname.lastname@example.org> > numbers .filter odd .map (^2)
> looks much better and easier to understand
Most of us like to read from left to right, as a chain of operations.
Functional people have a larger stack than most, so they're used to
everything being prefix ;)
In a more Lua-ish form:
To do this without little functions like odd and square is awkward:
numbers:filter(function(n) return math.mod(n,2)==1
end):map(function(x) return x*x end)
That's basically the argument for the short form ;)
Sometimes in this discussion the word 'convenience' has been used as
if it could be a bad thing, as if it would lead to some kind of moral
degeneracy. Also, there is an assumption that the aim is to make Lua
look like Haskell or Lua. Well, I don't use these languages, I just
like the functional style when it is _appropriate_ and the short form
makes it more pleasant.