curry a function to take arguments in multiple calls in PHP

PHP

🤖 Code Explanation

echo $add(5)(6); // 11
?>

This code written in PHP defines a function called "curry" which can be used to create new functions from existing functions. The new functions created by "curry" will have the same functionality as the original function, but with some of the arguments pre-filled. In the example given, the "add" function is used to create two new functions, each of which takes one argument and adds it to a pre-defined value.

Download SpellBox today