@@ 221-230 (lines=10) @@ | ||
218 | * @param callable $predicates... |
|
219 | * @return callable |
|
220 | */ |
|
221 | function all() { |
|
222 | $predicates = func_get_args(); |
|
223 | return _curry_one(function($value) use(&$predicates) { |
|
224 | foreach ($predicates as $predicate) { |
|
225 | if (! $predicate($value)) |
|
226 | return false; |
|
227 | } |
|
228 | return true; |
|
229 | }); |
|
230 | } |
|
231 | ||
232 | /** |
|
233 | * Takes many predicates and returns a new predicate that |
|
@@ 255-264 (lines=10) @@ | ||
252 | * @param callable $predicates... |
|
253 | * @return callable |
|
254 | */ |
|
255 | function any() { |
|
256 | $predicates = func_get_args(); |
|
257 | return _curry_one(function($value) use(&$predicates) { |
|
258 | foreach ($predicates as $predicate) { |
|
259 | if ($predicate($value)) |
|
260 | return true; |
|
261 | } |
|
262 | return false; |
|
263 | }); |
|
264 | } |
|
265 | ||
266 | /** |
|
267 | * Takes a function `f` and returns a function `g` so that if `f` returns |