Add tasks for all the new languages

This commit is contained in:
Tina Müller 2016-12-05 23:44:36 +01:00
parent 9dc3c2bb62
commit bba7bfd280
13208 changed files with 134745 additions and 0 deletions

View 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

View 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

View file

@ -0,0 +1,3 @@
def identity( n ) = vector( n, n, \r, c -> if r == c then 1 else 0 )
println( identity(3) )

View 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)))

View 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))

View 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

View 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

View 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(' ');
}
}

View 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;
});
});
}

View file

@ -0,0 +1,5 @@
@let {
im ^(%^\@table ^(@+ =) @to)
!im 4
}

View file

@ -0,0 +1,3 @@
def identity(n):
[range(0;n) | 0] as $row
| reduce range(0;n) as $i ([]; . + [ $row | .[$i] = 1 ] );

View file

@ -0,0 +1 @@
identity(4)

View file

@ -0,0 +1,3 @@
def identity(n):
reduce range(0;n) as $i
(0 | matrix(n;n); .[$i][$i] = 1);