News Feed
Jobs Feed
Sections



Recent Jobs

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



Similar Posts

Zend Developer Zone: Data-centric Adobe Flash Builder development with the Zend Framework

RIAZone: Integrating PHP with Flash Collaboration Services

Ian Selby's Blog: Create a REST API with PHP

Tiffany Brown's Blog: PHP quickie: is_numeric() versus ctype_digit()

DevShed: Working with the Email Class in Code Igniter


Community Events

phpnw10 PHP Conference 09/10/2010




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


suggestion plugin jquery wordpress conference symfony book zendframework unittest development developer framework phpunit library application azure database opinion example codeigniter

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