This is a creation in Article, where the information may have evolved or changed.
1. Basic usage: a = append (A, b ...) For example: List = appened (list,[]int{1,2,3,4} ...) Can be used to merge two of lists. Don't do this: list: = Make ([]int,len (List1) +len (List2)) and then copy (list,list1) copy (List[len (list1):],list2) 2, copy:b = make ([]t , Len (a)) copy (b, a) or: b = Append ([]t (Nil), a ...) 3, cut:a = Append (A[:i], a[j:] ...) 4, delete:a = Append (A[:i], a[i+1:] ...) Or: A = A[:i+copy (a[i:], a[i+1:]) [For example: A[len (a)-1], a = nil, append (A[:i], a[i+1:] ...) 5, Delete without preserving order:a[i], a = A[len (a)-1], A[:len (a)-1] For example: A[i], A[len (a)-1], a = A[len (a)-1], nil, A[:len (a) -1]6, expand:a = Append (A[:i], append (Make ([]t, J), A[i:] ...) ...) 7, extend:a = Append (A, make ([]t, J) ...) 8, insert:a = Append (A[:i], append ([]t{x}, A[i:] ...) ...) For example: s = append (s, 0) copy (s[i+1:], S[i:]) s[i] = x9, insertvector:a = Append (A[:i], append (b, a[i:] ...) ...) 10, pop x, a = A[len (a)-1], A[:len (a) -1]11, Push: a = Append (A, X) 12, Shift x, A: = A[0], a[1:]13, Unshift A = append ([]t{x},A ...) 14, reversing:for I: = Len (a)/2-1; I >= 0; i--{opp: = Len (a) -1-i a[i], A[opp] = A[opp], A[i]}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.