@@ 968-981 (lines=14) @@ | ||
965 | * @param array $list |
|
966 | * @return mixed |
|
967 | */ |
|
968 | function findLastIndex() { |
|
969 | static $findLastIndex = false; |
|
970 | $findLastIndex = $findLastIndex ?: curry(function($predicate, $list) { |
|
971 | $keys = array_keys($list); |
|
972 | $index = count($keys) - 1; |
|
973 | while ($index >= 0) { |
|
974 | if ($predicate($list[$keys[$index]])) |
|
975 | return $keys[$index]; |
|
976 | $index --; |
|
977 | } |
|
978 | return null; |
|
979 | }); |
|
980 | return _apply($findLastIndex, func_get_args()); |
|
981 | } |
|
982 | ||
983 | /** |
|
984 | * Returns the first item satisfying the predicate in |
|
@@ 1025-1038 (lines=14) @@ | ||
1022 | * @param array $list |
|
1023 | * @return mixed |
|
1024 | */ |
|
1025 | function findLast() { |
|
1026 | static $findLast = false; |
|
1027 | $findLast = $findLast ?: curry(function($predicate, $list) { |
|
1028 | $keys = array_keys($list); |
|
1029 | $index = count($keys) - 1; |
|
1030 | while ($index >= 0) { |
|
1031 | if ($predicate($list[$keys[$index]])) |
|
1032 | return $list[$keys[$index]]; |
|
1033 | $index --; |
|
1034 | } |
|
1035 | return null; |
|
1036 | }); |
|
1037 | return _apply($findLast, func_get_args()); |
|
1038 | } |
|
1039 | ||
1040 | /** |
|
1041 | * Returns the index of an item/substring in a list/string. |