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

@ -0,0 +1 @@
select j as i, i as j, value from A;

View file

@ -0,0 +1,22 @@
create or replace table A (i integer, j integer, value float );
insert into A values
(1, 1, 1),
(1, 2, 2),
(1, 3, 3),
(2, 1, 2),
(2, 2, 5),
(2, 3, 7);
# transposition
create or replace table AT as
(select j as i, i as j, value from A);
.print The matrix-like representation of A:
create or replace table AMatrix as (pivot A on j using max(value) order by i);
from AMatrix;
.print Convert the matrix-like representation back to the (i,j,value) representation:
unpivot AMatrix on columns('^[1-9]') into name j VALUE value;
.print The matrix-like representation of "A transpose":
pivot AT on j using max(value) order by i;

View file

@ -0,0 +1,5 @@
# Note that if the input is not rectangular, the output might be lossy.
create or replace function transpose(lst) as (
select list_transform( range(1, 1+length(lst[1])),
j -> list_transform(range(1, length(lst)+1),
i -> lst[i][j]) ));