Code Duplication    Length = 11-11 lines in 2 locations

src/list.php 2 locations

@@ 554-564 (lines=11) @@
551
 * @param  array $list
552
 * @return array
553
 */
554
function takeWhile() {
555
    static $takeWhile = false;
556
    $takeWhile = $takeWhile ?: curry(function($predicate, $list) {
557
        $first = head($list);
558
        return (null == $first || !$predicate($first))
559
            ? []
560
            : prepend($first, takeWhile($predicate, tail($list)));
561
562
    });
563
    return _apply($takeWhile, func_get_args());
564
}
565
566
/**
567
 * Same as `takeWhile` but taking elements from the end of the array.
@@ 581-591 (lines=11) @@
578
 * @param  array $list
579
 * @return array
580
 */
581
function takeLastWhile() {
582
    static $takeLastWhile = false;
583
    $takeLastWhile = $takeLastWhile ?: curry(function($predicate, $list) {
584
        $last = last($list);
585
        return (null == $last || !$predicate($last))
586
            ? []
587
            : append($last, takeLastWhile($predicate, init($list)));
588
589
    });
590
    return _apply($takeLastWhile, func_get_args());
591
}
592
593
/**
594
 * Takes elements from an array **until** the predicate