News Feed
Sections




News Archive
feed this:

Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Sebastian Bergmann's Blog:
Map and Reduce in PHP
February 20, 2008 @ 09:31:00

In this new blog entry, Sebastian Bergmann talks about two bits of functionality that PHP has that bring it a bit closer to a full functional language - array_map and array_reduce.

Just like Python, PHP is not a full-fledged functional language, but it supports some very useful functional idioms such as map and reduce. A blog posting by Scott Moonen on Functional Python prompted me to write this posting on PHP's array_map() and array_reduce() functions that apply callback functions to arrays.

He includes examples of each (in the functional context) showing how you can map callbacks to the array values, one that adds one to each number in the array and the other that combines the values and returns the sum.

0 comments voice your opinion now!
functional language arraymap arrayreduce example


Metapundit.net:
Partial function application in PHP
February 14, 2007 @ 07:54:00

On the Metapundit.net site, there's a new (long) entry that takes a look at one of the programming styles, functional programming, and checks into its support in PHP. Unfortunately, it's mostly a swing and a miss.

I should just get this straight right off the bat: you can't really do much functional programing in PHP. Functions are not first class citizens and the equivalent of passing functions around is passing around strings or arrays and relying on convention. No really.

He goes on by illustrating the point that PHP can do this sort of thing but only up to a point. Once you start to get into anonymous functions and moving past things like the array_map function, you start to loose a foothold. The create_function function allows for a bit more flexibility, but still doesn't fulfill the requirements needed for full support.

0 comments voice your opinion now!
partial function application arraymap createfunction programming partial function application arraymap createfunction programming



Community Events





Don't see your event here?
Let us know!


development api release deployment interview list framework community tips zendserver podcast conference series threedevsandamaybe laravel code introduction bugfix symfony language

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework