[go: up one dir, main page]

Menu

[r41]: / LIBVEC.MPL  Maximize  Restore  History

Download this file

19 lines (11 with data), 320 Bytes

+LIBDEF

HEAP=0

USEVEC(V,N)[HEAP=V;!V=N*.INT;V!N=0]

MEMUSED(;P,R)[R=0;P=HEAP;!P@!P<0?[R-=!P;P-=!P],P+=!P;R]

VECNEW(N;V,R)[
  N=(N+1)*.INT;V=HEAP;
  !V@[!V<0@V-=!V;R=V;!V>0@V+=!V;!R=V-R;N<=!R?[!(R+N)=!R-N;!R=-N;=R+.INT]]
]

VECEND(V)V?V!-1<0?V!-1=-V!-1

MALLOC(A)VECNEW((A+1)/.INT)
FREE(P)VECEND(P)