mergeshift := proc(l1num,l1off,l2num,l2off,OutputList,offset,dir,Lists,bits2) local c,d,m; for m to bits2 do c := l1off + dir * (m - 1) mod bits2: if c <= 0 then c := bits2 + c fi: d := l2off + dir * (m - 1) mod bits2: if d <= 0 then d := bits2 + d fi: OutputList[offset + m - 1] := cat(Lists[l1num][c],Lists[l2num][d]): od: end: