Left out deltas0 and deltas1, so I coded them in bc: define void deltas0(p[], *q[]) { auto i, v; v = 0; for(i = 1; i <= p[0]; ++i) { q[i] = p[i] - v; v = p[i]; } q[0] = p[0]; }
define void deltas1(p[], *q[]) { auto i, v; if(p[0] == 0) { q[0] = p[0]; return; } v = p[1]; for(i = 2; i <= p[0]; ++i) { q[i - 1] = p[i] - v; v = p[i]; } q[0] = p[0] - 1; }
define bpnxor(n) { auto x, r, s, m, p[], b, e; s = scale; scale = 0; basep(n, p[]); m = bp2binstr(p[]); b = obase; obase = 2; print "n:",n,"\n"; print "m:",m,"\n"; r = 0; while((n != 0) || (m != 0)) { if(n % 2 != m % 2) { r = r + 1; } n = n / 2; m = m / 2; r = r * 2; } r = r / 2; print "r:",r,"\n"; e = 0; while(r != 0) { e = e + (r % 2); r = r / 2; e = e * 2; } e = e / 2; print "e:",e,"\n"; scale = s; obase = b; return e; }
/* func1f is the function called on 1 ... n; input, output are scalar ints */ define void func1(n, *o[]) { auto i; o[0] = n; for(i = 1; i <= n; ++i) { o[i] = func1f(i); } }
define void bitlist(m, *q[]) { auto x, r, s, n, b; s = scale; scale = 0; b = obase; obase = 2; n = m; print "m:",m,"\n"; r = 0; while(m != 0) { r = r + 1; m = m / 2; } print "n:",n,"\n"; obase = b; print "r:",r,"\n"; q[0] = r; for(x = 0; x < r; ++x) { q[r - x] = n % 2; n = n / 2; } scale = s; }
define unbitlist(p[]) { auto x, s; s = 0; for(x = p[0]; x > 0; --x) { if(p[x]) { s = s + 2 ^ (p[0] - x); } } return s; }
FUNC1: -> N F << 1 N FOR X X NEXT N ->LIST 1 F DOLIST >>
UNBITLIST: << DUP 0 -> M N << LIST-> 1 SWAP FOR X X DUP 2 SWAP 1 - ^ SWAP 1 + PICK * N + 'N' STO NEXT M SIZE 1 SWAP FOR X DROP NEXT N >>
BITLIST: << DUP -> N M << IF N 0 == THEN { } ELSE WHILE N REPEAT N 2 MOD N 2 / ->NUM FLOOR 'N' STO END M 2 * LN 2 LN / ->NUM FLOOR ->LIST REVLIST END >>
define void deltas0(p[], *q[]) { auto i, v; v = 0; for(i = 1; i <= p[0]; ++i) { q[i] = p[i] - v; v = p[i]; } q[0] = p[0]; }
define void deltas1(p[], *q[]) { auto i, v; if(p[0] == 0) { q[0] = p[0]; return; } v = p[1]; for(i = 2; i <= p[0]; ++i) { q[i - 1] = p[i] - v; v = p[i]; } q[0] = p[0] - 1; }
define bpnxor(n) { auto x, r, s, m, p[], b, e; s = scale; scale = 0; basep(n, p[]); m = bp2binstr(p[]); b = obase; obase = 2; print "n:",n,"\n"; print "m:",m,"\n"; r = 0; while((n != 0) || (m != 0)) { if(n % 2 != m % 2) { r = r + 1; } n = n / 2; m = m / 2; r = r * 2; } r = r / 2; print "r:",r,"\n"; e = 0; while(r != 0) {
e = e + (r % 2); r = r / 2; e = e * 2; } e = e / 2; print "e:",e,"\n"; scale = s; obase = b; return e; }
/* func1f is the function called on 1 ... n; input, output are scalar ints */ define void func1(n, *o[]) { auto i; o[0] = n; for(i = 1; i <= n; ++i
( ... )
Comments 7
BASEP SWAP BASEP SWAP SQUID BP2NUM
Reply
define void deltas0(p[], *q[]) {
auto i, v;
v = 0;
for(i = 1; i <= p[0]; ++i) {
q[i] = p[i] - v;
v = p[i];
}
q[0] = p[0];
}
define void deltas1(p[], *q[]) {
auto i, v;
if(p[0] == 0) {
q[0] = p[0];
return;
}
v = p[1];
for(i = 2; i <= p[0]; ++i) {
q[i - 1] = p[i] - v;
v = p[i];
}
q[0] = p[0] - 1;
}
Reply
auto x, r, s, m, p[], b, e;
s = scale;
scale = 0;
basep(n, p[]);
m = bp2binstr(p[]);
b = obase;
obase = 2;
print "n:",n,"\n";
print "m:",m,"\n";
r = 0;
while((n != 0) || (m != 0)) {
if(n % 2 != m % 2) {
r = r + 1;
}
n = n / 2;
m = m / 2;
r = r * 2;
}
r = r / 2;
print "r:",r,"\n";
e = 0;
while(r != 0) {
e = e + (r % 2);
r = r / 2;
e = e * 2;
}
e = e / 2;
print "e:",e,"\n";
scale = s;
obase = b;
return e;
}
/* func1f is the function called on 1 ... n; input, output are scalar ints */
define void func1(n, *o[]) {
auto i;
o[0] = n;
for(i = 1; i <= n; ++i) {
o[i] = func1f(i);
}
}
define func1f(n) {
return bpnxor(n);
}
Reply
auto x, r, s, n, b;
s = scale;
scale = 0;
b = obase;
obase = 2;
n = m;
print "m:",m,"\n";
r = 0;
while(m != 0) {
r = r + 1;
m = m / 2;
}
print "n:",n,"\n";
obase = b;
print "r:",r,"\n";
q[0] = r;
for(x = 0; x < r; ++x) {
q[r - x] = n % 2;
n = n / 2;
}
scale = s;
}
define unbitlist(p[]) {
auto x, s;
s = 0;
for(x = p[0]; x > 0; --x) {
if(p[x]) {
s = s + 2 ^ (p[0] - x);
}
}
return s;
}
FUNC1:
-> N F << 1 N FOR X X NEXT N ->LIST 1 F DOLIST >>
UNBITLIST:
<< DUP 0 -> M N << LIST-> 1 SWAP FOR X X DUP 2
SWAP 1 - ^ SWAP 1 + PICK * N + 'N' STO NEXT M
SIZE 1 SWAP FOR X DROP NEXT N >>
BITLIST:
<< DUP -> N M << IF N 0 == THEN {
} ELSE WHILE N REPEAT N 2 MOD
N 2 / ->NUM FLOOR 'N' STO END M
2 * LN 2 LN / ->NUM FLOOR ->LIST
REVLIST END >>
Reply
auto i, v;
v = 0;
for(i = 1; i <= p[0]; ++i) {
q[i] = p[i] - v;
v = p[i];
}
q[0] = p[0];
}
define void deltas1(p[], *q[]) {
auto i, v;
if(p[0] == 0) {
q[0] = p[0];
return;
}
v = p[1];
for(i = 2; i <= p[0]; ++i) {
q[i - 1] = p[i] - v;
v = p[i];
}
q[0] = p[0] - 1;
}
define bpnxor(n) {
auto x, r, s, m, p[], b, e;
s = scale;
scale = 0;
basep(n, p[]);
m = bp2binstr(p[]);
b = obase;
obase = 2;
print "n:",n,"\n";
print "m:",m,"\n";
r = 0;
while((n != 0) || (m != 0)) {
if(n % 2 != m % 2) {
r = r + 1;
}
n = n / 2;
m = m / 2;
r = r * 2;
}
r = r / 2;
print "r:",r,"\n";
e = 0;
while(r != 0) {
e = e + (r % 2);
r = r / 2;
e = e * 2;
}
e = e / 2;
print "e:",e,"\n";
scale = s;
obase = b;
return e;
}
/* func1f is the function called on 1 ... n; input, output are scalar ints */
define void func1(n, *o[]) {
auto i;
o[0] = n;
for(i = 1; i <= n; ++i ( ... )
Reply
Leave a comment