Code Duplication    Length = 10-10 lines in 4 locations

src/list.php 4 locations

@@ 616-625 (lines=10) @@
613
 * @param  array $list
614
 * @return array
615
 */
616
function takeLastWhile() {
617
    static $takeLastWhile = false;
618
    $takeLastWhile = $takeLastWhile ?: curry(function($predicate, $list) {
619
        $index = length($list) - 1;
620
        while ($index >= 0 && $predicate($list[$index]))
621
            $index --;
622
        return array_slice($list, $index + 1);
623
    });
624
    return _apply($takeLastWhile, func_get_args());
625
}
626
627
/**
628
 * Takes elements from an array **until** the predicate
@@ 670-679 (lines=10) @@
667
 * @param  array $list
668
 * @return array
669
 */
670
function takeLastUntil() {
671
    static $takeLastUntil = false;
672
    $takeLastUntil = $takeLastUntil ?: curry(function($predicate, $list) {
673
        $index = length($list) - 1;
674
        while ($index >= 0 && !$predicate($list[$index]))
675
            $index --;
676
        return array_slice($list, $index + 1);
677
    });
678
    return _apply($takeLastUntil, func_get_args());
679
}
680
681
/**
682
 * Removes a number of elements from an array.
@@ 767-776 (lines=10) @@
764
 * @param  array $list
765
 * @return array
766
 */
767
function removeLastWhile() {
768
    static $removeLastWhile = false;
769
    $removeLastWhile = $removeLastWhile ?: curry(function($predicate, $list) {
770
        $index = length($list) - 1;
771
        while ($index >= 0 && $predicate($list[$index]))
772
            $index --;
773
        return array_slice($list, 0, $index + 1);
774
    });
775
    return _apply($removeLastWhile, func_get_args());
776
}
777
778
/**
779
 * Removes elements from an array **until** the predicate
@@ 823-832 (lines=10) @@
820
 * @param  array $list
821
 * @return array
822
 */
823
function removeLastUntil() {
824
    static $removeLastUntil = false;
825
    $removeLastUntil = $removeLastUntil ?: curry(function($predicate, $list) {
826
        $index = length($list) - 1;
827
        while ($index >= 0 && !$predicate($list[$index]))
828
            $index --;
829
        return array_slice($list, 0, $index + 1);
830
    });
831
    return _apply($removeLastUntil, func_get_args());
832
}
833
834
/**
835
 * Converts an array of (key, value) pairs to an object (instance of `stdClass`).