samewith
ErrorsCollection

samewith

Synthesised documentation from language/functions

From language/functions

See Original text in context

samewith calls the multi again with arguments provided at the call site and returns the value provided by the call. This can be used for self-recursion.

proto factorial(|) {*}
 
multi factorial(Int $x where * ≤ 1{ 1 }
multi factorial(Int $x{
    $x * samewith($x-1);
}
 
say (factorial 10); # OUTPUT: «36288000␤»