Man or boy test

This solution avoids creating the closure B if $k <= 0 (that is, nearly every time).

sub A($k is copy, &x1, &x2, &x3, &x4, &x5) {
    $k <= 0
        ?? x4() + x5()
        !! (my &B = { A(--$k, &B, &x1, &x2, &x3, &x4) })();
};

say A(10, {1}, {-1}, {-1}, {1}, {0});

Output:

-67