| @@ 180-189 (lines=10) @@ | ||
| 177 | * @param callable $predicates... |
|
| 178 | * @return callable |
|
| 179 | */ |
|
| 180 | function all() { |
|
| 181 | $predicates = func_get_args(); |
|
| 182 | return _curry_one(function($value) use(&$predicates) { |
|
| 183 | foreach ($predicates as $predicate) { |
|
| 184 | if (! $predicate($value)) |
|
| 185 | return false; |
|
| 186 | } |
|
| 187 | return true; |
|
| 188 | }); |
|
| 189 | } |
|
| 190 | ||
| 191 | /** |
|
| 192 | * Takes many predicates and returns a new predicate that |
|
| @@ 214-223 (lines=10) @@ | ||
| 211 | * @param callable $predicates... |
|
| 212 | * @return callable |
|
| 213 | */ |
|
| 214 | function any() { |
|
| 215 | $predicates = func_get_args(); |
|
| 216 | return _curry_one(function($value) use(&$predicates) { |
|
| 217 | foreach ($predicates as $predicate) { |
|
| 218 | if ($predicate($value)) |
|
| 219 | return true; |
|
| 220 | } |
|
| 221 | return false; |
|
| 222 | }); |
|
| 223 | } |
|
| 224 | ||
| 225 | /** |
|
| 226 | * Takes a function `f` and returns a function `g` so that if `f` returns |
|