| @@ 271-279 (lines=9) @@ | ||
| 268 | * @param array|string $list |
|
| 269 | * @return array |
|
| 270 | */ |
|
| 271 | function reverse () { |
|
| 272 | static $reverse = false; |
|
| 273 | $reverse = $reverse ?: curry(function($list) { |
|
| 274 | return is_string($list) |
|
| 275 | ? strrev($list) |
|
| 276 | : array_reverse($list); |
|
| 277 | }); |
|
| 278 | return _apply($reverse, func_get_args()); |
|
| 279 | } |
|
| 280 | ||
| 281 | /** |
|
| 282 | * Alias for `count()` and `strlen()`. |
|
| @@ 295-303 (lines=9) @@ | ||
| 292 | * @param array|string $list |
|
| 293 | * @return int |
|
| 294 | */ |
|
| 295 | function length() { |
|
| 296 | static $length = false; |
|
| 297 | $length = $length ?: curry(function($list) { |
|
| 298 | return is_string($list) |
|
| 299 | ? strlen($list) |
|
| 300 | : count($list); |
|
| 301 | }); |
|
| 302 | return _apply($length, func_get_args()); |
|
| 303 | } |
|
| 304 | ||
| 305 | /** |
|
| 306 | * Checks if the `$predicate` is verified by **all** items of the array. |
|
| @@ 912-920 (lines=9) @@ | ||
| 909 | * @param array|string $list |
|
| 910 | * @return bool |
|
| 911 | */ |
|
| 912 | function contains() { |
|
| 913 | static $contains = false; |
|
| 914 | $contains = $contains ?: curry(function($item, $list) { |
|
| 915 | return is_string($list) |
|
| 916 | ? (strpos($list, $item) !== false) |
|
| 917 | : in_array($item, $list); |
|
| 918 | }); |
|
| 919 | return _apply($contains, func_get_args()); |
|
| 920 | } |
|
| 921 | ||
| 922 | /** |
|
| 923 | * Returns the position/key of the first item satisfying the |
|