| @@ 12-21 (lines=10) @@ | ||
| 9 | * |
|
| 10 | * @return mixed |
|
| 11 | */ |
|
| 12 | function filter() |
|
| 13 | { |
|
| 14 | $args = func_get_args(); |
|
| 15 | ||
| 16 | $filter = function (\Closure $fn, array $ls) { |
|
| 17 | return array_filter($ls, $fn); |
|
| 18 | }; |
|
| 19 | ||
| 20 | return call_user_func_array(curry($filter), $args); |
|
| 21 | } |
|
| 22 | ||
| @@ 12-21 (lines=10) @@ | ||
| 9 | * |
|
| 10 | * @return mixed |
|
| 11 | */ |
|
| 12 | function reduce() |
|
| 13 | { |
|
| 14 | $args = func_get_args(); |
|
| 15 | ||
| 16 | $reduce = function (\Closure $fn, array $ls, $initial = null) { |
|
| 17 | return array_reduce($ls, $fn, $initial); |
|
| 18 | }; |
|
| 19 | ||
| 20 | return call_user_func_array(curry($reduce), $args); |
|
| 21 | } |
|
| 22 | ||