go append function common operations

1. After the intercept b is added to the elements of the slice A: A = the append (A, b ...)
2. Copy the elements of a slice to a new slice b:
1. b = make([]T, len(a))
2. copy(b, a)
3. Delete the element at index i:
a = append(a[:i], a[i+1:]...)
4. cut a slice from the element index i to j position: a = the append (a [: i], a [j:] ...)
The slices a j-th element extension length: a = the append (a, the make ([] T, j) ...)
6. Insert the element x in position of the index i: A = the append (A [: i], the append ([]} x {T, A [i:] ...) ...)
7. In the position of the insertion length index i j, new tiles: A = the append (A [: i], the append (the make ([] T, j), A [i:] ...) ...)
8. Insert b slices at the position index i of all the elements: A = the append (A [: i], the append (b, A [i:] ...) ...)
9. Remove the end sections located at a most elements X: X, a = a [len (a) -1], a [: len (a) -1]
10. The element x appended to sections A: A = the append (A, x)
Thus, you can use the slicing operation and append a sequence of any variable length.
From a mathematical point of view, slice corresponding to the vector, if desired, a vector can be defined as a slice alias to operate.
If you need a more complete solution, you can learn about Eleanor McHugh written several packages: slices , catena alberghiera and Lists .

Guess you like

Origin www.cnblogs.com/niuben/p/12310805.html