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
20
Task/Identity-matrix/ERRE/identity-matrix.erre
Normal file
20
Task/Identity-matrix/ERRE/identity-matrix.erre
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
PROGRAM IDENTITY
|
||||
|
||||
!$DYNAMIC
|
||||
DIM A[0,0]
|
||||
|
||||
BEGIN
|
||||
PRINT(CHR$(12);) ! CLS
|
||||
INPUT("Matrix size",N%)
|
||||
!$DIM A[N%,N%]
|
||||
FOR I%=1 TO N% DO
|
||||
A[I%,I%]=1
|
||||
END FOR
|
||||
! print matrix
|
||||
FOR I%=1 TO N% DO
|
||||
FOR J%=1 TO N% DO
|
||||
WRITE("###";A[I%,J%];)
|
||||
END FOR
|
||||
PRINT
|
||||
END FOR
|
||||
END PROGRAM
|
||||
32
Task/Identity-matrix/FreeBASIC/identity-matrix.freebasic
Normal file
32
Task/Identity-matrix/FreeBASIC/identity-matrix.freebasic
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
' FB 1.05.0 Win64
|
||||
|
||||
Dim As Integer n
|
||||
|
||||
Do
|
||||
Input "Enter size of matrix "; n
|
||||
Loop Until n > 0
|
||||
|
||||
Dim identity(1 To n, 1 To n) As Integer '' all zero by default
|
||||
|
||||
' enter 1s in diagonal elements
|
||||
For i As Integer = 1 To n
|
||||
identity(i, i) = 1
|
||||
Next
|
||||
|
||||
' print identity matrix if n < 40
|
||||
Print
|
||||
|
||||
If n < 40 Then
|
||||
For i As Integer = 1 To n
|
||||
For j As Integer = 1 To n
|
||||
Print identity(i, j);
|
||||
Next j
|
||||
Print
|
||||
Next i
|
||||
Else
|
||||
Print "Matrix is too big to display on 80 column console"
|
||||
End If
|
||||
|
||||
Print
|
||||
Print "Press any key to quit"
|
||||
Sleep
|
||||
3
Task/Identity-matrix/FunL/identity-matrix.funl
Normal file
3
Task/Identity-matrix/FunL/identity-matrix.funl
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def identity( n ) = vector( n, n, \r, c -> if r == c then 1 else 0 )
|
||||
|
||||
println( identity(3) )
|
||||
8
Task/Identity-matrix/LFE/identity-matrix-1.lfe
Normal file
8
Task/Identity-matrix/LFE/identity-matrix-1.lfe
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
(defun identity
|
||||
((`(,m ,n))
|
||||
(identity m n))
|
||||
((m)
|
||||
(identity m m)))
|
||||
|
||||
(defun identity (m n)
|
||||
(lists:duplicate m (lists:duplicate n 1)))
|
||||
6
Task/Identity-matrix/LFE/identity-matrix-2.lfe
Normal file
6
Task/Identity-matrix/LFE/identity-matrix-2.lfe
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
> (identity 3)
|
||||
((1 1 1) (1 1 1) (1 1 1))
|
||||
> (identity 3 3)
|
||||
((1 1 1) (1 1 1) (1 1 1))
|
||||
> (identity '(3 3))
|
||||
((1 1 1) (1 1 1) (1 1 1))
|
||||
5
Task/Identity-matrix/Nim/identity-matrix.nim
Normal file
5
Task/Identity-matrix/Nim/identity-matrix.nim
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
proc identityMatrix(n): auto =
|
||||
result = newSeq[seq[int]](n)
|
||||
for i in 0 .. < result.len:
|
||||
result[i] = newSeq[int](n)
|
||||
result[i][i] = 1
|
||||
25
Task/Identity-matrix/Ring/identity-matrix.ring
Normal file
25
Task/Identity-matrix/Ring/identity-matrix.ring
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
size = 5
|
||||
im = newlist(size, size)
|
||||
identityMatrix(size, im)
|
||||
for r = 1 to size
|
||||
for c = 1 to size
|
||||
see im[r][c]
|
||||
next
|
||||
see nl
|
||||
next
|
||||
|
||||
func identityMatrix s, m
|
||||
m = newlist(s, s)
|
||||
for i = 1 to s
|
||||
m[i][i] = 1
|
||||
next
|
||||
return m
|
||||
|
||||
func newlist x, y
|
||||
if isstring(x) x=0+x ok
|
||||
if isstring(y) y=0+y ok
|
||||
alist = list(x)
|
||||
for t in alist
|
||||
t = list(y)
|
||||
next
|
||||
return alist
|
||||
12
Task/Identity-matrix/Sidef/identity-matrix.sidef
Normal file
12
Task/Identity-matrix/Sidef/identity-matrix.sidef
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
func identity_matrix(n) {
|
||||
1..n -> map { |i|
|
||||
1..n -> map {|j| j == i ? 1 : 0 }
|
||||
}
|
||||
}
|
||||
|
||||
(ARGV.len ? ARGV.map{.to_i} : [4, 5, 6]) -> each { |n|
|
||||
say "\n#{n}:";
|
||||
identity_matrix(n).each { |row|
|
||||
say row.join(' ');
|
||||
}
|
||||
}
|
||||
7
Task/Identity-matrix/Sparkling/identity-matrix.sparkling
Normal file
7
Task/Identity-matrix/Sparkling/identity-matrix.sparkling
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
function unitMatrix(n) {
|
||||
return map(range(n), function(k1, v1) {
|
||||
return map(range(n), function(k2, v2) {
|
||||
return v2 == v1 ? 1 : 0;
|
||||
});
|
||||
});
|
||||
}
|
||||
5
Task/Identity-matrix/Wortel/identity-matrix.wortel
Normal file
5
Task/Identity-matrix/Wortel/identity-matrix.wortel
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
@let {
|
||||
im ^(%^\@table ^(@+ =) @to)
|
||||
|
||||
!im 4
|
||||
}
|
||||
3
Task/Identity-matrix/jq/identity-matrix-1.jq
Normal file
3
Task/Identity-matrix/jq/identity-matrix-1.jq
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def identity(n):
|
||||
[range(0;n) | 0] as $row
|
||||
| reduce range(0;n) as $i ([]; . + [ $row | .[$i] = 1 ] );
|
||||
1
Task/Identity-matrix/jq/identity-matrix-2.jq
Normal file
1
Task/Identity-matrix/jq/identity-matrix-2.jq
Normal file
|
|
@ -0,0 +1 @@
|
|||
identity(4)
|
||||
3
Task/Identity-matrix/jq/identity-matrix-3.jq
Normal file
3
Task/Identity-matrix/jq/identity-matrix-3.jq
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
def identity(n):
|
||||
reduce range(0;n) as $i
|
||||
(0 | matrix(n;n); .[$i][$i] = 1);
|
||||
Loading…
Add table
Add a link
Reference in a new issue