Last active
March 23, 2022 07:53
Revisions
-
Abdul Rehman revised this gist
Nov 3, 2019 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -22,8 +22,8 @@ func main() { // Shrink for index, value := range intslice { if len(value) == 0 { fmt.Println("Cant shrink below 0") continue } -
Abdul Rehman revised this gist
Nov 3, 2019 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -28,8 +28,9 @@ func main() { } value = value[:len(value)-1] intslice[index] = value if index == len(intslice)-1 { intslice = intslice[:len(intslice)-1] } -
Abdul Rehman revised this gist
Nov 3, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,10 +30,10 @@ func main() { value = value[:len(value)-1] if index == len(value)-1 { intslice = intslice[:len(intslice)-1] } } fmt.Println(intslice) -
Abdul Rehman revised this gist
Nov 3, 2019 . No changes.There are no files selected for viewing
-
Abdul Rehman created this gist
Nov 3, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ package main import "fmt" func main() { intslice := [][]int{[]int{1}, []int{2}} // Grow for index, value := range intslice { value = append(value, 0) intslice[index] = value } insertion := []int{} for index := 0; index < len(intslice)+1; index++ { insertion = append(insertion, 0) } intslice = append(intslice, insertion) fmt.Println(intslice) // Shrink for index, value := range intslice { if len(value) == 1 { fmt.Println("Cant shrink to 0") continue } value = value[:len(value)-1] if index == len(value)-1 { } intslice = intslice[:index] } fmt.Println(intslice) } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # grows the list by list[len(list[n])+1][len(list[n][n])+1] pythonlist = [[1], [2]] for index, i in enumerate(pythonlist): pythonlist[index].append(0) pythonlist.append([]) for i in range(len(pythonlist)): pythonlist[-1].append(0) # Shrink print(pythonlist) # shrinks the list by list[len(list[n])-1][len(list[n][n])-1] for index, i in enumerate(pythonlist): pythonlist[index].pop() pythonlist.pop() print(pythonlist)