Cramer's rule: Difference between revisions
→{{header|Racket}}
(→{{header|jq}}: fix bug) |
Dr-neptune (talk | contribs) |
||
Line 2,311:
=={{header|Racket}}==
#lang racket
(require math/matrix)
(define sys
(matrix [[2 -1 5 1]
(define soln
▲<syntaxhighlight lang="racket">#lang typed/racket
(define (matrix-set-column M new-col idx)
(matrix-augment (list-set (matrix-cols M) idx new-col)))
(define
(let ([denom (matrix-determinant M)]
▲ [3 2 2 -6]
(letrec ([roots (λ (position)
▲ [5 -2 -3 3]]))
(cons (/ (matrix-determinant
(matrix-set-column M soln position))
denom)
(roots (add1 position)))))])
(map cons '(w x y z) (roots 0)))))
(cramers-rule sys soln)
</syntaxhighlight>
▲ -32
▲ -47
▲ 49]))
{{out}}
<pre>'
=={{header|Raku}}==
|