| @@ 190-199 (lines=10) @@ | ||
| 187 | * @param callable $predicates... |
|
| 188 | * @return callable |
|
| 189 | */ |
|
| 190 | function all() { |
|
| 191 | $predicates = func_get_args(); |
|
| 192 | return _curry_one(function($value) use(&$predicates) { |
|
| 193 | foreach ($predicates as $predicate) { |
|
| 194 | if (! $predicate($value)) |
|
| 195 | return false; |
|
| 196 | } |
|
| 197 | return true; |
|
| 198 | }); |
|
| 199 | } |
|
| 200 | ||
| 201 | /** |
|
| 202 | * Takes many predicates and returns a new predicate that |
|
| @@ 224-233 (lines=10) @@ | ||
| 221 | * @param callable $predicates... |
|
| 222 | * @return callable |
|
| 223 | */ |
|
| 224 | function any() { |
|
| 225 | $predicates = func_get_args(); |
|
| 226 | return _curry_one(function($value) use(&$predicates) { |
|
| 227 | foreach ($predicates as $predicate) { |
|
| 228 | if ($predicate($value)) |
|
| 229 | return true; |
|
| 230 | } |
|
| 231 | return false; |
|
| 232 | }); |
|
| 233 | } |
|
| 234 | ||
| 235 | /** |
|
| 236 | * Takes a function `f` and returns a function `g` so that if `f` returns |
|