And most of those functions generally are not used with array literals (because the array is the data you're workin on/transforming, just do the transformation statically if you have an array literal), so array literals don't have much value for such a library, it only improves the examples.
For all of its other sins, simple functional programming (that is, first-order functions and the basic uses thereof, rather than immutability and the other more modern FP characteristics) is easier than in most languages. In fact it's easier in Perl than in Erlang, a putatively-functional language!
The last one for comparison. Erlang can do better with a list comprehension, though:
[X * 2 | X <- [1, 2, 3]]
which except for case also works for Haskell. But that exclusively works with only map and filter (in Erlang [1]), Erlang is still surprisingly klunkier than Perl for everything else (folds, actually passing functions around, etc).
Comments
This will be even more aesthetically pleasing once PHP 5.4 is released with support for array literals:
That, combined with array dereferencing (ie, explode(",",$str)[0] ), PHP will start to look a lot like JavaScript.> This will be even more aesthetically
You're asserting it's currently pleasing...
And most of those functions generally are not used with array literals (because the array is the data you're workin on/transforming, just do the transformation statically if you have an array literal), so array literals don't have much value for such a library, it only improves the examples.
> PHP will start to look a lot like Perl.
You had a typo, there.
For all of its other sins, simple functional programming (that is, first-order functions and the basic uses thereof, rather than immutability and the other more modern FP characteristics) is easier than in most languages. In fact it's easier in Perl than in Erlang, a putatively-functional language!
The last one for comparison. Erlang can do better with a list comprehension, though: which except for case also works for Haskell. But that exclusively works with only map and filter (in Erlang [1]), Erlang is still surprisingly klunkier than Perl for everything else (folds, actually passing functions around, etc).[1]: Haskell recently re-added monad comprehensions, so comprehensions aren't as limited anymore. http://blog.n-sch.de/2010/11/27/fun-with-monad-comprehension...
This. is. not. reddit. No FTFY type of comments please.