|
@@ 311-317 (lines=7) @@
|
| 308 |
|
* @param array $list |
| 309 |
|
* @return bool |
| 310 |
|
*/ |
| 311 |
|
function allSatisfies() { |
| 312 |
|
static $allSatisfies = false; |
| 313 |
|
$allSatisfies = $allSatisfies ?: curry(function($predicate, $list) { |
| 314 |
|
return length(filter($predicate, $list)) == length($list); |
| 315 |
|
}); |
| 316 |
|
return _apply($allSatisfies, func_get_args()); |
| 317 |
|
} |
| 318 |
|
|
| 319 |
|
/** |
| 320 |
|
* Checks if the `$predicate` is verified by **any** item of the array. |
|
@@ 472-478 (lines=7) @@
|
| 469 |
|
* @param array $list |
| 470 |
|
* @return array |
| 471 |
|
*/ |
| 472 |
|
function append() { |
| 473 |
|
static $append = false; |
| 474 |
|
$append = $append ?: curry(function ($item, $list) { |
| 475 |
|
return insert(length($list), $item, $list); |
| 476 |
|
}); |
| 477 |
|
return _apply($append, func_get_args()); |
| 478 |
|
} |
| 479 |
|
|
| 480 |
|
/** |
| 481 |
|
* Inserts an item at the begining of an array or a substring at the begining of a string. |
|
@@ 690-696 (lines=7) @@
|
| 687 |
|
* @param array $list |
| 688 |
|
* @return array |
| 689 |
|
*/ |
| 690 |
|
function removeWhile() { |
| 691 |
|
static $removeWhile = false; |
| 692 |
|
$removeWhile = $removeWhile ?: curry(function($predicate, $list) { |
| 693 |
|
return remove(length(takeWhile($predicate, $list)), $list); |
| 694 |
|
}); |
| 695 |
|
return _apply($removeWhile, func_get_args()); |
| 696 |
|
} |
| 697 |
|
|
| 698 |
|
/** |
| 699 |
|
* Same as `removeWhile` but removes elements from the end of the array. |
|
@@ 713-719 (lines=7) @@
|
| 710 |
|
* @param array $list |
| 711 |
|
* @return array |
| 712 |
|
*/ |
| 713 |
|
function removeLastWhile() { |
| 714 |
|
static $removeLastWhile = false; |
| 715 |
|
$removeLastWhile = $removeLastWhile ?: curry(function($predicate, $list) { |
| 716 |
|
return remove(- length(takeLastWhile($predicate, $list)), $list); |
| 717 |
|
}); |
| 718 |
|
return _apply($removeLastWhile, func_get_args()); |
| 719 |
|
} |
| 720 |
|
|
| 721 |
|
/** |
| 722 |
|
* Removes elements from an array **until** the predicate |
|
@@ 738-744 (lines=7) @@
|
| 735 |
|
* @param array $list |
| 736 |
|
* @return array |
| 737 |
|
*/ |
| 738 |
|
function removeUntil() { |
| 739 |
|
static $removeUntil = false; |
| 740 |
|
$removeUntil = $removeUntil ?: curry(function($predicate, $list) { |
| 741 |
|
return remove(length(takeUntil($predicate, $list)), $list); |
| 742 |
|
}); |
| 743 |
|
return _apply($removeUntil, func_get_args()); |
| 744 |
|
} |
| 745 |
|
|
| 746 |
|
/** |
| 747 |
|
* Same as `removeUntil` but removes elements from the end of the array. |
|
@@ 762-768 (lines=7) @@
|
| 759 |
|
* @param array $list |
| 760 |
|
* @return array |
| 761 |
|
*/ |
| 762 |
|
function removeLastUntil() { |
| 763 |
|
static $removeLastUntil = false; |
| 764 |
|
$removeLastUntil = $removeLastUntil ?: curry(function($predicate, $list) { |
| 765 |
|
return remove(- length(takeLastUntil($predicate, $list)), $list); |
| 766 |
|
}); |
| 767 |
|
return _apply($removeLastUntil, func_get_args()); |
| 768 |
|
} |
| 769 |
|
|
| 770 |
|
/** |
| 771 |
|
* Converts an array of (key, value) pairs to an object (instance of `stdClass`). |