%%off %%off % Author Martin Ruckert PREFIX :ListCat: H IS $0 Parameter m IS $1 j IS $2 Local variables p IS $3 q IS $4 head IS $5 tail IS $6 :ListCat IS @ BZ m,9F %%on ListCat SL j,m,3 \hfil$1$ SUB j,j,8 \hfil$1$ LDOU tail,H,j \hfil$1$ & Initialize \.{tail}. JMP 0F \hfil$1$ & Loop on $j$. %%% 1H LDOU head,H,j \hfil$M-1$ BZ head,0F \hfil$M-1+2E$ & Skip empty heads. SET q,head \hfil$M-1-E$ %%% 2H SET p,q \hfil$N-L$ & Bump $p$ and $q$ to the end of the list. LDOU q,p \hfil$N-L$ PBNZ q,2B \hfil$N-L$ %%% STOU tail,p \hfil$M-1-E$ & Concatenate lists. SET tail,head \hfil$M-1-E$ & Advance to the next list. 0H SUB j,j,8 \hfil$M$ & PBNN j,1B \hfil$M$ &$0\le j < m-1$ STOU head,H,0 \hfil$1$ POP 0,0 %%off 9H POP 0,0 PREFIX :