Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
27
Task/Matrix-arithmetic/EchoLisp/matrix-arithmetic.echolisp
Normal file
27
Task/Matrix-arithmetic/EchoLisp/matrix-arithmetic.echolisp
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
(lib 'list)
|
||||
(lib 'matrix)
|
||||
|
||||
;; adapted from Racket
|
||||
(define (permanent M)
|
||||
(let (( n (matrix-row-num M)))
|
||||
(for/sum ([σ (in-permutations n)])
|
||||
(for/product ([i n] [σi σ])
|
||||
(array-ref M i σi)))))
|
||||
|
||||
;; output
|
||||
(define A (list->array '(1 2 3 4) 2 2))
|
||||
(array-print A)
|
||||
1 2
|
||||
3 4
|
||||
(determinant A) → -2
|
||||
(permanent A) → 10
|
||||
|
||||
(define M (list->array (iota 25) 5 5))
|
||||
(array-print M)
|
||||
0 1 2 3 4
|
||||
5 6 7 8 9
|
||||
10 11 12 13 14
|
||||
15 16 17 18 19
|
||||
20 21 22 23 24
|
||||
(determinant M) → 0
|
||||
(permanent M) → 6778800
|
||||
Loading…
Add table
Add a link
Reference in a new issue