Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,21 +0,0 @@
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
procedure Test_Loop_Nested is
type Value_Type is range 1..20;
package Random_Values is new Ada.Numerics.Discrete_Random (Value_Type);
use Random_Values;
Dice : Generator;
A : array (1..10, 1..10) of Value_Type :=
(others => (others => Random (Dice)));
begin
Outer :
for I in A'Range (1) loop
for J in A'Range (2) loop
Put (Value_Type'Image (A (I, J)));
exit Outer when A (I, J) = 20;
end loop;
New_Line;
end loop Outer;
end Test_Loop_Nested;

View file

@ -1,45 +0,0 @@
IDENTIFICATION DIVISION.
PROGRAM-ID. Nested-Loop.
DATA DIVISION.
LOCAL-STORAGE SECTION.
78 Table-Size VALUE 10.
01 Table-Area.
03 Table-Row OCCURS Table-Size TIMES
INDEXED BY Row-Index.
05 Table-Element PIC 99 OCCURS Table-Size TIMES
INDEXED BY Col-Index.
01 Current-Time PIC 9(8).
PROCEDURE DIVISION.
* *> Seed RANDOM.
ACCEPT Current-Time FROM TIME
MOVE FUNCTION RANDOM(Current-Time) TO Current-Time
* *> Put random numbers in the table.
* *> The AFTER clause is equivalent to a nested PERFORM VARYING
* *> statement.
PERFORM VARYING Row-Index FROM 1 BY 1
UNTIL Table-Size < Row-Index
AFTER Col-Index FROM 1 BY 1
UNTIL Table-Size < Col-Index
COMPUTE Table-Element (Row-Index, Col-Index) =
FUNCTION MOD((FUNCTION RANDOM * 1000), 20) + 1
END-PERFORM
* *> Search through table for 20.
* *> Using proper nested loops.
PERFORM VARYING Row-Index FROM 1 BY 1
UNTIL Table-Size < Row-Index
PERFORM VARYING Col-Index FROM 1 BY 1
UNTIL Table-Size < Col-Index
IF Table-Element (Row-Index, Col-Index) = 20
EXIT PERFORM
ELSE
DISPLAY Table-Element (Row-Index, Col-Index)
END-IF
END-PERFORM
END-PERFORM
GOBACK
.

View file

@ -1,16 +0,0 @@
use Random;
var nums:[1..10, 1..10] int;
var rnd = new RandomStream();
[ n in nums ] n = floor(rnd.getNext() * 21):int;
delete rnd;
// this shows a clumsy explicit way of iterating, to actually create nested loops:
label outer for i in nums.domain.dim(1) {
for j in nums.domain.dim(2) {
write(" ", nums(i,j));
if nums(i,j) == 20 then break outer;
}
writeln();
}

View file

@ -1,18 +0,0 @@
sequence a
a = rand(repeat(repeat(20, 10), 10))
integer wantExit
wantExit = 0
for i = 1 to 10 do
for j = 1 to 10 do
printf(1, "%g ", {a[i][j]})
if a[i][j] = 20 then
wantExit = 1
exit
end if
end for
if wantExit then
exit
end if
end for

View file

@ -1,38 +0,0 @@
REBOL [
Title: "Loop/Nested"
URL: http://rosettacode.org/wiki/Loop/Nested
]
; Number formatting.
zeropad: func [pad n][
n: to-string n insert/dup n "0" (pad - length? n) n]
; Initialize random number generator from current time.
random/seed now
; Create array and fill with random numbers, range 1..20.
soup: array [10 10]
foreach row soup [forall row [row/1: random 20]]
print "Loop break using state variable:"
done: no
for y 1 10 1 [
for x 1 10 1 [
prin rejoin [zeropad 2 soup/:x/:y " "]
if 20 = soup/:x/:y [done: yes break]
]
prin crlf
if done [break]
]
print [crlf "Loop break with catch/throw:"]
catch [
for y 1 10 1 [
for x 1 10 1 [
prin rejoin [zeropad 2 soup/:x/:y " "]
if 20 = soup/:x/:y [throw 'done]
]
prin crlf
]
]
prin crlf

View file

@ -1,20 +0,0 @@
let m = []
for _ in 0 to 9 {
let n = []
for _ in 0 to 9 {
let _ = Js.Array2.push(n, 1 + Js.Math.random_int(0, 20))
}
let _ = Js.Array2.push(m, n)
}
try {
for i in 0 to 9 {
for j in 0 to 9 {
Js.log(m[i][j])
if m[i][j] == 20 { raise(Exit) }
}
}
} catch {
| Exit => Js.log("stop")
}