Bracmat concatenates lists composed with the comma, space, addition and multiplication operators. Furthermore, lists composed with the addition and multiplication operators are canonically sorted and like terms or factors are combined algebraically. Lists composed with the space operator automatically delete any elements with zero-length atoms and no prefixes. All these lists except the comma-separated list support a notion of 'array index', but as the underlying datastructure is a linked list and not an array, accessing, say, the millionth element can be slow. Examples of concatenation (entered on the Bracmat command line):

type TReturnArray =arrayofinteger;//you need to define a type to be able to return it

function ConcatArray(a1,a2:arrayofinteger):TReturnArray;var i,r:integer;begin{ Low(array) is not necessarily 0 }SetLength(result,High(a1)-Low(a1)+High(a2)-Low(a2)+2);//BAD idea to set a length you won't release, just to show the idea! r:=0;//index on the result may be different to indexes on the sourcesfor i :=Low(a1)toHigh(a1)dobegin result[r]:= a1[i];Inc(r);end;for i :=Low(a2)toHigh(a2)dobegin result[r]:= a2[i];Inc(r);end;end;

func main(){// Example 1: Idiomatic in Go is use of the append function.// Elements must be of identical type. a :=[]int{1,2,3} b :=[]int{7,12,60}// these are technically slices, not arrays c := append(a, b...) fmt.Println(c)

// Example 2: Polymorphism.// interface{} is a type too, one that can reference values of any type.// This allows a sort of polymorphic list.i:=[]interface{}{1,2,3} j :=[]interface{}{"Crosby","Stills","Nash","Young"} k := append(i, j...)// append will allocate as needed fmt.Println(k)

// Example 3: Arrays, not slices.// A word like "array" on RC often means "whatever array means in your// language." In Go, the common role of "array" is usually filled by// Go slices, as in examples 1 and 2. If by "array" you really mean// "Go array," then you have to do a little extra work. The best// technique is almost always to create slices on the arrays and then// use the copy function. l :=[...]int{1,2,3} m :=[...]int{7,12,60}// arrays have constant size set at compile timevar n [len(l)+len(m)]intcopy(n[:], l[:])// [:] creates a slice that references the entire arraycopy(n[len(l):], m[:]) fmt.Println(n)

}

Output:

[1 2 3 7 12 60]
[1 2 3 Crosby Stills Nash Young]
[1 2 3 7 12 60]

Array concatenation needs can vary. Here is another set of examples that illustrate different techniques.

Array concatenation can mean different things, depending on the number of dimensions of the arguments and the result. In the simplest case, with 1-dimensional arrays to begin with, there are two obvious ways to concatenate them. If my arrays are these:

If a and b are two arrays, then a+b is their concatenation.
Similarly for a+b+c. To concatenate the component arrays of an array, A, the flatten filter is available in recent versions of jq. If your jq does not have flatten, then the task can be accomplished by:

reduce A[] as $a ([]; . + $a)

jq also supports streams, which are somewhat array-like, so it may be worth mentioning that the concatenation of two or more streams can be accomplished using "," instead of "+".

Use the Build Array function.This image is a VI Snippet, an executable image of LabVIEW code. The LabVIEW version is shown on the top-right hand corner. You can download it, then drag-and-drop it onto the LabVIEW block diagram from a file browser, and it will appear as runnable, editable code.

There is a built-in procedure for concatenating arrays (and similar objects such as matrices or vectors). Arrays can be concatenated along any given dimension, which is specified as the first argument.

Lists, in Maple, might be considered to be a kind of "array" (in the sense that they look like arrays in memory), though they are actually immutable objects. However, they can be concatenated as follows.

Two arrays are concatenated by placing the two arrays between a pair of square brackets. A space between the two array names will concatenate them horizontally, and a semi-colon between array names will concatenate vertically.

It could be "as simple as array1 + array2", but the 'array' module names the operation 'append' rather than '+'. It's tempting to just say that Mercury supports ad-hoc polymorphism - it can infer that a bare '+' refers to 'float.+' or 'int.+' (or that the 'append' above is array.append, rather than list.append), by the types involved - but it also handles other ambiguities in the same way. For instance, Mercury (like Prolog and Erlang) treats the arity of a function as part of its name, where a(1, 2) and a(1) involve the distinct functions a/2 and a/1. But Mercury also (unlike Prolog and Erlang) supports currying, where a(1) is a function that accepts a/2's second argument. So, is [a(X), a(Y), a(Z)] a list of whatever type a/1 evaluates to, or is it a list of curried a/2?

Order supports two main aggregate types: tuples and sequences (similar to lists in other languages). Most "interesting" operations are limited to sequences, but both support an append operation, and each can be converted to the other.

An alternative, that can be used to advantage for matrices
as well as vectors, follows. This example illustrates
extending a matrix diagonally. Although fixed array bounds
are used in the declarations, the bounds can be dynamic.
Matrix B is extended by placing matrix C on its diagonal:

If a and b are lists, augment(a, b) concatenates them in the usual fashion. If a and b are matrices, then augment(a, b) produces a matrix whose columns are the columns of a followed by the columns of b, i.e. an augmented matrix.