RosettaCodeData/Task/Array-concatenation/BASIC/array-concatenation-2.basic

20 lines
551 B
Plaintext

DIM a(3), b(4)
a() = 1, 2, 3, 4
b() = 5, 6, 7, 8, 9
PROCconcat(a(), b(), c())
FOR i% = 0 TO DIM(c(),1)
PRINT c(i%)
NEXT
END
DEF PROCconcat(a(), b(), RETURN c())
LOCAL s%, na%, nb%
s% = ^a(1) - ^a(0) : REM Size of each array element
na% = DIM(a(),1)+1 : REM Number of elements in a()
nb% = DIM(b(),1)+1 : REM Number of elements in b()
DIM c(na%+nb%-1)
SYS "RtlMoveMemory", ^c(0), ^a(0), s%*na%
SYS "RtlMoveMemory", ^c(na%), ^b(0), s%*nb%
ENDPROC