rfc:operator_functions
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revision | Last revisionBoth sides next revision | ||
rfc:operator_functions [2017/09/09 21:25] – fix partial application example ajf | rfc:operator_functions [2017/09/09 21:32] – include partial apply sample ajf | ||
---|---|---|---|
Line 62: | Line 62: | ||
<code php> | <code php> | ||
// Select only the positive numbers | // Select only the positive numbers | ||
- | $positiveSubset = array_filters($numbers, partialApply('<', | + | $positiveSubset = array_filter($numbers, partialApply('<', |
</ | </ | ||
+ | |||
+ | An example working partial application implementation would be: | ||
+ | |||
+ | <file php partialApply.php> | ||
+ | function partialApply(callable $c, ...$args) { | ||
+ | return function (...$args2) use ($c, $args) { | ||
+ | return $c(...$args, | ||
+ | }; | ||
+ | } | ||
+ | </ | ||
==== Detail ==== | ==== Detail ==== |
rfc/operator_functions.txt · Last modified: 2017/09/22 13:28 by 127.0.0.1