You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

31 lines
2.2 KiB

#include"a.h" // ngn/k, (c) 2019-2021 ngn, GNU AGPLv3 - https://codeberg.org/ngn/k/blob/master/LICENSE
SN A flt(Ax,Ay,Cb)_(Er(!ytT,x,y)Au=rshL(0,yR);
i(yN,Az=app(x,A(get(y,i)),1);B(!z,u=u(0))B(!ztz,u=et2(u,z))Ln=gl(z);B(n!=(UI)n,u=ed1(u))j(b?n:!n,uq(get(y,i))))x(y(u)))
S A rs(Ax/*0*/,Nm,N*pj,L*s,N r)_(Nn=absL(*s);P(r>1,Ay=aA(n);i(n,ya=rs(x,m,pj,s+1,r-1))y)
Ct=tT(xt);Y(t&&!xn,x=cn[t])Lj=*s>=0?*pj:(m-n%m)%m,w=ZT[t],q=min(m-j,n);*pj=(j+n)%m;Ay=atn(t,n);Mc(yC,xC+j*w,q*w);
Mc(yC+q*w,xC,min(j,n-q)*w);W(2*m<=n,Mc(yC+m*w,yC,m*w);m*=2)Y(n>m,Mc(yC+m*w,yC,(n-m)*w))Y(t==tA,y=sqz(mRa(y)))y)
A2(rsh,XF(flt(x,y,1))Ym(Xz(Az=kv(&y);xR;y=N2(x,z,rsh(x,y));z=N1(y,rsh(x,z));am(y,z))x=enla(x);xR;am(x,ap1(y,x)))
YM(y=mut(y);yy=ear(cv('#'),A(x,yy),2);y)Yt(rsh(x,enl(y)))
x=enla(Ny(gL(x)));Nn=xn;P(!n,fir(x(y)))P(n>8,ez2(x,y))P(n==1&&*xL==NL,x(y))P(!yn,rsh(x,enl(fir(y))))
i(n,Lv=xl;Y(v<0,Ed(n>2||n==2&&v-NL,x,y)
P(n==2,Ed(*xL<=0&&xL[1]<=0||!yn,x,y)*xL==NL?K("{x@:1;(x*!1+(-x)!-1+#y)_y}",x,y):K("{x@:0;((-x)!(#y)*!x)_y}",x,y))))
Nj=0;x(y(rs(y,yn,&j,xL,n))))
A rshL(Ln,Ax)_(rsh(az(n),x))
A2(cut,XF(flt(x,y,0))Ym(K("{((!y)^x)#y}",x,y))
YT(x=Ny(gL(x));K("{n:#y;y$[x~*x;$[n<x|-x;!0;x<0;!n+0^x;x+!n-x];$[|/0<':x,#y;`err\"dom\";x+!'1_-':x,#y]]}",x,y))
Yz(Et(!xtT,x,y)Li=gl(y);P(!in(i,xn),x)
Az=atn(xt,xn-1);L w=ZT[xt];Mc(zC,xC,i*w);Mc(zC+i*w,xC+i*w+w,(xn-i-1)*w);Y(xtA,z=sqz(mRa(z)))x(z))
et2(x,y))
A1(enl,P(xtl||xtd,AT(tT(xt),mut(x)))P(xtcz||xts,atnv(tT(xt),1,&x))Xm(Ay=kv(&x);aM(x,eac1(y,enl)))a1(x))
A1(enla,Xmt(enl(x))x)
A2(cat,
P(xtmM&&ytmM,P(xtm&&ytm,Az=kv(&y);amd(A(x,y,av0,z),4))Ed(!mtc_(xx,yx),x,y)
Az=eac2(_R(xy),_R(yy),cv(','));x(y(z?aM(_R(xx),z):0)))
x=enla(x);P(!xn,x(enla(y)))P(ytT&&!yn,y(x))y=enla(y);Y(xtZ&&ytzZ,N(sup(&x,&y)))Y(xt-yt,x=blw(x);y=blw(y))
Nm=xn,n=yn;x=room(x,m+n);Mc(xC+m*ZT[xt],yC,n*ZT[xt]);y(!ytA?0:yr-1?mRa(y):AN(0,y));x)
A2(apd,XM(P(!ytm||!mtc_(xx,yx),apd(Ny(blw(x)),y))x=mut(x);Az=xy=mut(xy);i(zn,_q(za,get(yy,i)))y(x))
Q(xtT);P(xtZ&&ytz,N(sup(&x,&y));ytP?apv(x,&y):y(apv(x,yC)))
P(!xtA&&(!ytt||xt-tT(yt)),cat(x,enl(y)))P(!xn,enl(x(y)))Lv=xtA?(L)y:gl(y);apv(x,&v))
A apv(Ax,OV*v )_(Q(xtT);Nn=xn;x=room(x,n+1);Mc(xC+n*ZT[xt],v,ZT[xt]);x)
A apc(Ax,Cc )_(Q(xtC);Nn=xn;x=room(x,n+1);xC[n]=c;x)
A cts(Ax,Qs,Nm)_(Q(xtC);Nn=xn;x=room(x,n+m);Mc(xC+n,s,m);x)