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
5
Task/Matrix-arithmetic/FunL/matrix-arithmetic-1.funl
Normal file
5
Task/Matrix-arithmetic/FunL/matrix-arithmetic-1.funl
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
def sgn( p ) = product( (if s(0) < s(1) xor i(0) < i(1) then -1 else 1) | (s, i) <- p.combinations(2).zip( (0:p.length()).combinations(2) ) )
|
||||
|
||||
def perm( m ) = sum( product(m(i, sigma(i)) | i <- 0:m.length()) | sigma <- (0:m.length()).permutations() )
|
||||
|
||||
def det( m ) = sum( sgn(sigma)*product(m(i, sigma(i)) | i <- 0:m.length()) | sigma <- (0:m.length()).permutations() )
|
||||
7
Task/Matrix-arithmetic/FunL/matrix-arithmetic-2.funl
Normal file
7
Task/Matrix-arithmetic/FunL/matrix-arithmetic-2.funl
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
def perm( m )
|
||||
| m.length() == 1 and m(0).length() == 1 = m(0, 0)
|
||||
| otherwise = sum( m(i, 0)*perm(m(0:i, 1:m.length()) + m(i+1:m.length(), 1:m.length())) | i <- 0:m.length() )
|
||||
|
||||
def det( m )
|
||||
| m.length() == 1 and m(0).length() == 1 = m(0, 0)
|
||||
| otherwise = sum( (-1)^i*m(i, 0)*det(m(0:i, 1:m.length()) + m(i+1:m.length(), 1:m.length())) | i <- 0:m.length() )
|
||||
18
Task/Matrix-arithmetic/FunL/matrix-arithmetic-3.funl
Normal file
18
Task/Matrix-arithmetic/FunL/matrix-arithmetic-3.funl
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
matrices = [
|
||||
( (1, 2),
|
||||
(3, 4)),
|
||||
( (-2, 2, -3),
|
||||
(-1, 1, 3),
|
||||
( 2, 0, -1)),
|
||||
( ( 1, 2, 3, 4),
|
||||
( 4, 5, 6, 7),
|
||||
( 7, 8, 9, 10),
|
||||
(10, 11, 12, 13)),
|
||||
( ( 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)) ]
|
||||
|
||||
for m <- matrices
|
||||
println( m, 'perm: ' + perm(m), 'det: ' + det(m) )
|
||||
Loading…
Add table
Add a link
Reference in a new issue