sub samewith

Documentation for sub samewith assembled from the following types:

language documentation Functions

From Functions

(Functions) sub samewith

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␤»