Cramer's rule: Difference between revisions
m
→{{header|Raku}}: some sigil-less, other changes for code-readability
Thundergnat (talk | contribs) m (syntax highlighting fixup automation) |
SqrtNegInf (talk | contribs) m (→{{header|Raku}}: some sigil-less, other changes for code-readability) |
||
Line 2,333:
(formerly Perl 6)
<syntaxhighlight lang="raku" line>sub det(@matrix) {
my @a = @matrix.map: { [|$_] };
my $sign =
my $pivot = 1;
for ^@a ->
my @r = (
my $previous-pivot = $pivot;
if 0 == ($pivot = @a[
(my
(@a[
my $pivot = @a[
$sign = -$sign;
}
for @r X @r -> (
((@a[
}
}
$sign
}
sub cramers_rule(@A, @terms) {
gather for ^@A ->
my @Ai = @A.map: { [|$_] };
for ^@terms ->
@Ai[
}
take det(@Ai);
Line 2,369:
);
my @free_terms =
my ($w, $x, $y, $z) =
("w = $w", "x = $x", "y = $y", "z = $z").join("\n").say;</syntaxhighlight>
{{out}}
<pre>
|