LoginLogin

Better way to insert arrays into arrays?

Root / Programming Questions / [.]

MZ952Created:
I had a library of functions I created a lonngg time ago that I treated like black boxes and never opened but now I find myself in this ugly position of recreating it all.
OPTION DEFINT
DEF INSERT_ARY A[],P,B[]
 DIM _A[0]
 COPY _A,A
 COPY A,P,B
 COPY A,LEN(A)-LEN(B),_A,P,LEN(A)-P
END
This has the disadvantages of requiring a copy of A in RAM and requiring 3 copy instructions. I must be unimaginative because I'm not coming up with a better method at the moment.

DEF INSERT_ARY A[],P,B[]
 COPY A,P+LEN(B),A,P,LEN(A)-P
 COPY A,P,B
END

Oh, so simple! My thought process should've been to set up A to fit in B, rather than to fit in B and fix up A. Thanks