Task

Show how to concatenate two arrays in your language.



If this is as simple as array1 + array2, so be it.




BYTE FUNC Concat(INT ARRAY src1,src2,dst BYTE size1,size2)
  BYTE i
 
  FOR i=0 TO size1-1
  DO
    dst(i)=src1(i)
  OD
  FOR i=0 TO size2-1
  DO
    dst(size1+i)=src2(i)
  OD
RETURN (size1+size2)
 
PROC PrintArray(INT ARRAY a BYTE size)
  BYTE i
 
  Put('[)
  FOR i=0 TO size-1
  DO
    PrintI(a(i))
    IF i<size-1 THEN
      Put(' )
    FI
  OD
  Put('])
RETURN
 
PROC Test(INT ARRAY src1,src2 BYTE size1,size2)
  INT ARRAY res(20)
  BYTE size
 
  size=Concat(src1,src2,res,size1,size2)
  PrintArray(src1,size1)
  Put('+)
  PrintArray(src2,size2)
  Put('=)
  PrintArray(res,size)
  PutE() PutE()
RETURN
 
PROC Main()
  INT ARRAY
    a1=[1 2 3 4],
    a2=[5 6 7 8 9 10],
    ;a workaround for a3=[-1 -2 -3 -4 -5]
    a3=[65535 65534 65533 65532 65531]
 
  Test(a1,a2,4,6)
  Test(a2,a1,6,4)
  Test(a3,a2,5,4)
RETURN