Data update

This commit is contained in:
Ingy döt Net 2025-08-11 18:05:26 -07:00
parent 4d5544505c
commit 4924dd0264
3073 changed files with 55820 additions and 4408 deletions

View file

@ -15,3 +15,8 @@
PRINT array(2) TAB(16) array(3) TAB(32) array(4)
PRINT array%(2) TAB(16) array%(3) TAB(32) array%(4)
PRINT array$(2) TAB(16) array$(3) TAB(32) array$(4)
REM Some versions of BBC BASIC support array slicing:
array(2 TO 4) = source(1 TO 3)
array(3 TO 5) = 2, 4, -1
array(3 TO 5) = array(4 TO 6)

View file

@ -0,0 +1,9 @@
# Insert `value` after row i (using IO=1) in a one-column table named t (a string).
create or replace function insert_after(i, value, t) as table (
(FROM query_table(t) LIMIT i)
union all
select value
union all (FROM query_table(t) OFFSET i)
);
from insert_after_row(1, 100, 't');

View file

@ -1,3 +1,3 @@
system'console.writeLine(array[0]);
system'console.writeLine(stackAllocatedArray[1]);
system'console.writeLine(dynamicArray[2]);
system'Console.writeLine(array[0]);
system'Console.writeLine(stackAllocatedArray[1]);
system'Console.writeLine(dynamicArray[2]);

View file

@ -0,0 +1,4 @@
10 DIM A(10), B$(10)
20 A(1) = 42
30 B$(10) = "TOWEL"
40 PRINT A(1), B$(10)

View file

@ -0,0 +1,22 @@
class Main {
static public function main():Void {
// Array (dynamic length)
var a = new Array<Int>();
for (i in 1...4)
a.push(i);
// alt: var a = [1, 2, 3];
// alt2: var a = [for (i in 1...4)];
for (i in 0...a.length)
trace(a[i]);
// Vector (fixed-length)
var v = new haxe.ds.Vector(3);
v[0] = 1;
v[1] = 2;
v[2] = 3;
for (i in 0...v.length)
trace(v[i]);
}
}

View file

@ -0,0 +1,8 @@
local array = {}
array:insert(42)
array:insert(43)
print(array:concat(", ")) -- 42, 43
print(array[1]) -- 42, since indexing starts at 1
print(#array) -- 2, since # is the length operator
array:clear()
print(#array) -- 0

View file

@ -1,56 +1,59 @@
-- 1 Jun 2025
-- 7 Aug 2025
include Settings
say 'ARRAYS'
say version
say
say 'A simple array...'
do i = 1 to 100
if Pos('Regina',version) > 0 then
call Library
say 'Simple array...'
do i = 1 to 10
a.i=i*i
end
say 'Square of' 5 'is' a.5
say 'Square of' 55 'is' a.55
say 'Square of' 3 'is' a.3
say 'Square of' 7 'is' a.7
say
say 'Mimic indexing...'
say 'Square of' 5 'is' a(5)
say 'Square of' 55 'is' a(55)
say 'Square of' 3 'is' a(3)
say 'Square of' 7 'is' a(7)
say
say 'A default value...'
b. = 'Out of range'
do i = 1 to 100
do i = 1 to 10
b.i=1/i
end
say 'Inverse of' 5 'is' b.5
say 'Inverse of' 55 'is' b.55
say 'Inverse of' 555 'is' b.555
say 'Inverse of' 3 'is' b.3
say 'Inverse of' 7 'is' b.7
say 'Inverse of' 11 'is' b.11
say
say 'An other index range...'
do i = -100 to 100
say 'Index zero...'
do i = 1 to 10
c.i=i*i*i
end
j=-55; say 'Cube of' j 'is' c.j
j=-5; say 'Cube of' j 'is' c.j
j=5; say 'Cube of' j 'is' c.j
j=55; say 'Cube of' j 'is' c.j
c.0=10
j=0; say 'Number of rows is' c.j
j=3; say 'Cube of' j 'is' c.j
j=7; say 'Cube of' j 'is' c.j
say
say 'A sparse array...'
d.='Not calculated'
do i = 2 by 2 to 100
say 'Sparse array...'
d.=0
do i = 3 by 3 to 9
d.i=-i
end
say 'Negative of' 55 'is' d.55
say 'Negative of' 56 'is' d.56
say 'Negative of' 3 'is' d.3
say 'Negative of' 7 'is' d.7
say
say 'Special indices...'
e.cat='civet'; say 'e.cat =' e.cat
a1='dog'; e.a1='pitbull'
a2=a1; say 'e.'a2 '=' e.a2
a1='x.y.z'; e.a1='periods'
a2=a1; say 'e.'a2 '=' e.a2
a1='x y z'; e.a1='spaces'
a2=a1; say 'e.'a2 '=' e.a2
a1=''; e.a1='specials'
a2=a1; say 'e.'a2 '=' e.a2
say 'More dimensions...'
e.=0
do i = 1 to 3
do j = 1 to 3
e.i.j=i*j
end
end
say '1x2 is' e.1.2
say '3x2 is' e.3.2
say
call SysDumpVariables
say
say 'Element has no value...'
signal off novalue
@ -64,4 +67,11 @@ procedure expose a.
arg xx
return a.xx
Library:
say 'Library...'
call RxFuncAdd 'SysLoadFuncs','RegUtil','SysLoadFuncs'
call SysLoadFuncs
say
return
include Abend

View file

@ -0,0 +1 @@
l := [: !&input :] # build a list of the lines read from standard input

View file

@ -0,0 +1,6 @@
procedure main()
L := [: 1 to 5:]
delete(L,4)
insert(L,2,"hello")
every write(!L)
end

View file

@ -0,0 +1,3 @@
L := list(5,0)
i := 0
every !L := (i+:=1)

View file

@ -0,0 +1,32 @@
const std = @import("std");
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
// array literal
const array1 = [9]i32{ 0, 1, 1, 2, 3, 5, 7, 12, 21 };
// infer the size of the array
const array2 = [_]i32{ 0, 1, 1, 2, 3, 5, 7, 12, 21 };
// alternative initialization using result location
const array3: [9]i32 = .{ 0, 1, 1, 2, 3, 5, 7, 12, 21 };
// initialize an array with zeros using array multiplication
var array4 = [_]i32{0} ** 5; // array length: 5
// assign elements to an array (must be declared as a variable)
array4[0] = -12;
array4[2] = 345;
array4[4] = -6;
// retieve elements from an array
try stdout.print("{d}, ", .{array4[0]});
try stdout.print("{d}, ", .{array4[1]});
try stdout.print("{d}, ", .{array4[2]});
try stdout.print("{d}, ", .{array4[3]});
try stdout.print("{d}\n", .{array4[4]});
// unused constants must be discarded
_ = array1; _ = array2; _ = array3;
}

View file

@ -0,0 +1,21 @@
const std = @import("std");
pub fn main() !void {
const stdout = std.io.getStdOut().writer();
var gpa = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gpa.allocator();
// ArrayLists are initialized in the heap
var array = std.ArrayList(i32).init(allocator);
defer array.deinit();
// pushing elements to an ArrayList
try array.append(-12);
try array.append(345);
try array.append(-7);
// retrieving elements from an ArrayList
try stdout.print("{d}, ", .{array.items[0]});
try stdout.print("{d}, ", .{array.items[1]});
try stdout.print("{d}\n", .{array.items[2]});
}