Code Duplication    Length = 10-10 lines in 2 locations

src/list.php 2 locations

@@ 478-487 (lines=10) @@
475
 * @param  array $list
476
 * @return array
477
 */
478
function takeWhile() {
479
    $takeWhile = function($predicate, $list) {
480
        $first = head($list);
481
        return (null == $first || !$predicate($first))
482
            ? []
483
            : prepend($first, takeWhile($predicate, tail($list)));
484
485
    };
486
    return apply(curry($takeWhile), func_get_args());
487
}
488
489
/**
490
 * Same as `takeWhile` but taking elements from the end of the array.
@@ 502-511 (lines=10) @@
499
 * @param  array $list
500
 * @return array
501
 */
502
function takeLastWhile() {
503
    $takeLastWhile = function($predicate, $list) {
504
        $last = last($list);
505
        return (null == $last || !$predicate($last))
506
            ? []
507
            : append($last, takeLastWhile($predicate, init($list)));
508
509
    };
510
    return apply(curry($takeLastWhile), func_get_args());
511
}
512
513
/**
514
 * Takes elements from an array **until** the predicate