News Feed
Sections




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

Timothy Boronczyk's Blog:
Currying in PHP
July 10, 2009 @ 13:33:18

Timothy Boronczyk has posted about an interesting concept you could use in your applications - currying (made possible in PHP 5.3.x and above):

What happens if you don't have all the arguments handy for a function, but you want to give whatever arguments you do have now and then provide the rest of them to the function later? This is called currying, and is a core concept in functional programming. It's messy, but possible to curry functions in PHP now that closures have been added.

He starts with an example from OCaml/F# to illustrate the point and moves to a PHP example - changing a normal function that requires three parameters into one that makes it possible to only submit the parameters you'd want to use. He also includes a more "real life" example of how it could be used in array filtering.

0 comments voice your opinion now!
usecase tutorial closures currying


blog comments powered by Disqus

Similar Posts

Zend Developer Zone: Using the Stack Exchange API with PHP (part 2)

Godaddyhostingreview Blog: How to move Magento from Production to Live Server

Developer Tutorials Blog: Digg Clone: Start your own Digg in five minutes flat with PHP

SitePoint PHP Blog: Database Versioning with DBV

AjaxRay.com: Extending Zend Form Element to create customized Phone number field


Community Events

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


library extension interview community series release psr7 development framework laravel5 podcast language laravel wordpress opinion introduction voicesoftheelephpant conference api unittest

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