Data update
This commit is contained in:
parent
4bb20c9b71
commit
cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions
4
Task/Identity-matrix/Ada/identity-matrix-1.adb
Normal file
4
Task/Identity-matrix/Ada/identity-matrix-1.adb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
-- As prototyped in the Generic_Real_Arrays specification:
|
||||
-- function Unit_Matrix (Order : Positive; First_1, First_2 : Integer := 1) return Real_Matrix;
|
||||
-- For the task:
|
||||
mat : Real_Matrix := Unit_Matrix(5);
|
||||
4
Task/Identity-matrix/Ada/identity-matrix-2.adb
Normal file
4
Task/Identity-matrix/Ada/identity-matrix-2.adb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
type Matrix is array(Positive Range <>, Positive Range <>) of Integer;
|
||||
mat : Matrix(1..5,1..5) := (others => (others => 0));
|
||||
-- then after the declarative section:
|
||||
for i in mat'Range(1) loop mat(i,i) := 1; end loop;
|
||||
4
Task/Identity-matrix/Pluto/identity-matrix.pluto
Normal file
4
Task/Identity-matrix/Pluto/identity-matrix.pluto
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
require "matrix"
|
||||
|
||||
local num_rows = 10 -- say
|
||||
print(matrix.identity(num_rows))
|
||||
6
Task/Identity-matrix/PowerShell/identity-matrix-1.ps1
Normal file
6
Task/Identity-matrix/PowerShell/identity-matrix-1.ps1
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
function identity($n) {
|
||||
0..($n-1) | foreach{$row = @(0) * $n; $row[$_] = 1; ,$row}
|
||||
}
|
||||
function show($a) { $a | foreach{ "$_"} }
|
||||
$array = identity 4
|
||||
show $array
|
||||
2
Task/Identity-matrix/PowerShell/identity-matrix-2.ps1
Normal file
2
Task/Identity-matrix/PowerShell/identity-matrix-2.ps1
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
$array[0][0]
|
||||
$array[0][1]
|
||||
7
Task/Identity-matrix/Rebol/identity-matrix-1.rebol
Normal file
7
Task/Identity-matrix/Rebol/identity-matrix-1.rebol
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
identity-matrix: function[size [integer!]][
|
||||
matrix: array/initial reduce [size size] 0
|
||||
repeat i size [matrix/:i/:i: 1]
|
||||
new-line/all matrix true
|
||||
matrix
|
||||
]
|
||||
probe identity-matrix 5
|
||||
9
Task/Identity-matrix/Rebol/identity-matrix-2.rebol
Normal file
9
Task/Identity-matrix/Rebol/identity-matrix-2.rebol
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
identity-matrix: function [size [integer!]][
|
||||
matrix: array/initial size * size 0 ;; Create a flat array with size^2 elements, all zeros
|
||||
repeat i size [
|
||||
matrix/((i - 1) * size + i): 1 ;; Set 1 on the diagonal: row-major position
|
||||
]
|
||||
new-line/skip matrix true size
|
||||
matrix
|
||||
]
|
||||
probe identity-matrix 5
|
||||
29
Task/Identity-matrix/VBScript/identity-matrix-1.vbs
Normal file
29
Task/Identity-matrix/VBScript/identity-matrix-1.vbs
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
build_matrix(7)
|
||||
|
||||
Sub build_matrix(n)
|
||||
Dim matrix()
|
||||
ReDim matrix(n-1,n-1)
|
||||
i = 0
|
||||
'populate the matrix
|
||||
For row = 0 To n-1
|
||||
For col = 0 To n-1
|
||||
If col = i Then
|
||||
matrix(row,col) = 1
|
||||
Else
|
||||
matrix(row,col) = 0
|
||||
End If
|
||||
Next
|
||||
i = i + 1
|
||||
Next
|
||||
'display the matrix
|
||||
For row = 0 To n-1
|
||||
For col = 0 To n-1
|
||||
If col < n-1 Then
|
||||
WScript.StdOut.Write matrix(row,col) & " "
|
||||
Else
|
||||
WScript.StdOut.Write matrix(row,col)
|
||||
End If
|
||||
Next
|
||||
WScript.StdOut.WriteLine
|
||||
Next
|
||||
End Sub
|
||||
15
Task/Identity-matrix/VBScript/identity-matrix-2.vbs
Normal file
15
Task/Identity-matrix/VBScript/identity-matrix-2.vbs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
n = 8
|
||||
|
||||
arr = Identity(n)
|
||||
|
||||
for i = 0 to n-1
|
||||
for j = 0 to n-1
|
||||
wscript.stdout.Write arr(i,j) & " "
|
||||
next
|
||||
wscript.stdout.writeline
|
||||
next
|
||||
|
||||
Function Identity (size)
|
||||
Execute Replace("dim a(#,#):for i=0 to #:for j=0 to #:a(i,j)=0:next:a(i,i)=1:next","#",size-1)
|
||||
Identity = a
|
||||
End Function
|
||||
Loading…
Add table
Add a link
Reference in a new issue