Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

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

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

View file

@ -0,0 +1,4 @@
require "matrix"
local num_rows = 10 -- say
print(matrix.identity(num_rows))

View 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

View file

@ -0,0 +1,2 @@
$array[0][0]
$array[0][1]

View 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

View 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

View 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

View 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