Code Duplication    Length = 11-11 lines in 4 locations

src/list.php 4 locations

@@ 589-599 (lines=11) @@
586
 * @param  array $list
587
 * @return array
588
 */
589
function takeWhile() {
590
    static $takeWhile = false;
591
    $takeWhile = $takeWhile ?: curry(function($predicate, $list) {
592
        $index = 0;
593
        $size = length($list);
594
        while ($index < $size && $predicate($list[$index]))
595
            $index ++;
596
        return array_slice($list, 0, $index);
597
    });
598
    return _apply($takeWhile, func_get_args());
599
}
600
601
/**
602
 * Same as `takeWhile` but taking elements from the end of the array.
@@ 643-653 (lines=11) @@
640
 * @param  array $list
641
 * @return array
642
 */
643
function takeUntil() {
644
    static $takeUntil = false;
645
    $takeUntil = $takeUntil ?: curry(function($predicate, $list) {
646
        $index = 0;
647
        $size = length($list);
648
        while ($index < $size && !$predicate($list[$index]))
649
            $index ++;
650
        return array_slice($list, 0, $index);
651
    });
652
    return _apply($takeUntil, func_get_args());
653
}
654
655
/**
656
 * Same as `takeUntil` but takes elements from the end of the array.
@@ 740-750 (lines=11) @@
737
 * @param  array $list
738
 * @return array
739
 */
740
function removeWhile() {
741
    static $removeWhile = false;
742
    $removeWhile = $removeWhile ?: curry(function($predicate, $list) {
743
        $index = 0;
744
        $size = length($list);
745
        while ($index < $size && $predicate($list[$index]))
746
            $index ++;
747
        return array_slice($list, $index);
748
    });
749
    return _apply($removeWhile, func_get_args());
750
}
751
752
/**
753
 * Same as `removeWhile` but removes elements from the end of the array.
@@ 795-805 (lines=11) @@
792
 * @param  array $list
793
 * @return array
794
 */
795
function removeUntil() {
796
    static $removeUntil = false;
797
    $removeUntil = $removeUntil ?: curry(function($predicate, $list) {
798
        $index = 0;
799
        $size = length($list);
800
        while ($index < $size && !$predicate($list[$index]))
801
            $index ++;
802
        return array_slice($list, $index);
803
    });
804
    return _apply($removeUntil, func_get_args());
805
}
806
807
/**
808
 * Same as `removeUntil` but removes elements from the end of the array.