News Feed
Sections




News Archive
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


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Using YAML With PHP and PECL

David Coallier's Blog: PHP Namespaces (Part 1: Basic usage & gotchas)

PHP Magazine: What Is Your Top Consideration for Choosing a CMS? (Poll)

PHPImpact Blog: From Swift Mailer to Zend_Mail

PHPMaster.com: Better Understanding Random


Community Events

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


programming example composer series application laravel php7 introduction project podcast community interview yii2 language opinion symfony part2 framework api list

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