Task

Show how to concatenate two arrays in your language.



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




 
module Main;
import 
	System.Collections.ArrayList as Array,
	System.Console as Console;
 
type 
	Vector =  array {math} * of integer;
 
procedure Concat(x,y: Vector): Vector;
var
	i,k: integer;
	res: Vector;
begin
	res := new Vector(len(x) + len(y));
	k := 0;
	for i := 0 to len(x) - 1 do
		res[k] := x[i];inc(k)
	end;
	for i := 0 to len(y) - 1 do
		res[k] := y[i];inc(k)
	end;
	return res
end Concat;
 
procedure Concat2(x,y: Array): Array;
var
	i: integer;
	res: Array;
begin
	res := new Array(x.Count + y.Count);
	for i := 0 to x.Count - 1 do
		res.Add(x[i]);
	end;
	for i := 0 to y.Count - 1 do
		res.Add(y[i]);
	end;
	return res
end Concat2;
 
procedure WriteVec(x: Vector);
var
	i: integer;
begin
	for i := 0 to len(x) - 1 do;
		write(x[i]:3)
	end;
	writeln;
end WriteVec;
 
procedure WriteAry(x: Array);
var
	i: integer;
begin
	for i := 0 to x.Count - 1 do;
		Console.Write("{0,3}",x[i])
	end;
	writeln;
end WriteAry;
 
var
	a,b: Vector;	
	x,y: Array;
begin
	a := [1,2,3,4];
	b := [6,7,8,9];
	WriteVec(Concat(a,b));
 
	x := new Array(4);
	y := new Array(4);
	x.Add(2);x.Add(4);x.Add(6);x.Add(8);
	y.Add(3);y.Add(5);y.Add(9);y.Add(11);
 
	WriteAry(Concat2(x,y));
end Main.
 