Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,5 @@
%swap: procedure (a, b);
declare (a, b) character;
return ( 't=' || a || ';' || a || '=' || b || ';' || b '=t;' );
%end swap;
%activate swap;

View file

@ -0,0 +1,16 @@
declare swap generic (
swapf when (float, float),
swapc when (char, char));
swapf: proc (a, b);
declare (a, b, t) float;
t = a; a = b; b = t;
end swapf;
swapc: proc (a, b);
declare (a, b) character(*);
declare t character (length(b));
t = a; a = b; b = t;
end swapc;
declare (r, s) character (5);
call swap (r, s);

View file

@ -0,0 +1,36 @@
%swap: proc(x,y);
dcl (x, y) char;
x = trim(x); /* Just for neatness sake */
y = trim(y);
ans('begin; ') skip;
ans(' dcl c char (1); ') skip;
ans(' dcl sx char (1) based(px); ') skip;
ans(' dcl sy char (1) based(py); ') skip;
ans(' dcl i fixed bin (31); ') skip;
ans(' dcl px ptr init (addr(' || x || ')); ') skip;
ans(' dcl py ptr init (addr(' || y || ')); ') skip;
ans(' do i = 1 to min(stg(' || x || '), stg(' || y || '));') skip;
ans(' c = sx; ') skip;
ans(' sx = sy; ') skip;
ans(' sy = c; ') skip;
ans(' px = px + 1; ') skip;
ans(' py = py + 1; ') skip;
ans(' end; ') skip;
ans('end; ') skip;
%end swap;
%act swap;
dcl c1 char (10) init ('1234567890');
dcl c2 char (10) init ('ABCDEFGHIJ');
dcl f1 fixed bin (31) init (12345);
dcl f2 fixed bin (31) init (98765);
put data(c1, c2, f1, f2);
swap(c1, c2);
swap(f1, f2);
put data(c1, c2, f1, f2);
f1 = -656877352; /* '5a5a5a5a'x, aka 'QQQQ' */
swapper(c1, f1);
put data(c1,f1);

View file

@ -0,0 +1,15 @@
begin;
dcl c char (1);
dcl sx char (1) based(px);
dcl sy char (1) based(py);
dcl i fixed bin (31);
dcl px ptr init (addr(C1));
dcl py ptr init (addr(C2));
do i = 1 to min(stg(C1), stg(C2));
c = sx;
sx = sy;
sy = c;
px = px + 1;
py = py + 1;
end;
end;

View file

@ -0,0 +1,4 @@
%Swap:Procedure(a,b);
declare (a,b) character; /*These are proper strings of arbitrary length, pre-processor only.*/
return ('Begin; declare t like '|| a ||'; t='|| a ||';'|| a ||'='|| b ||';'|| b ||'=t; End;');
%End Swap;

View file

@ -0,0 +1,6 @@
Begin;
declare t like this;
t = this;
this = that;
that = t;
End;