Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strconv"
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
|
|
|
|
"github.com/01-edu/z01"
|
|
|
|
|
|
|
|
correct "./correct"
|
|
|
|
student "./student"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Node10 = student.NodeL
|
|
|
|
type List10 = correct.List
|
|
|
|
type NodeS10 = correct.NodeL
|
|
|
|
type ListS10 = student.List
|
|
|
|
|
|
|
|
func listToStringStu12(l *ListS10) string {
|
|
|
|
var res string
|
|
|
|
it := l.Head
|
|
|
|
for it != nil {
|
|
|
|
switch it.Data.(type) {
|
|
|
|
case int:
|
|
|
|
res += strconv.Itoa(it.Data.(int)) + "-> "
|
|
|
|
case string:
|
|
|
|
res += it.Data.(string) + "-> "
|
|
|
|
}
|
|
|
|
it = it.Next
|
|
|
|
}
|
|
|
|
res += "<nil>"
|
|
|
|
return res
|
|
|
|
}
|
|
|
|
|
|
|
|
func listPushBackTest10(l *ListS10, l1 *List10, data interface{}) {
|
|
|
|
n := &Node10{Data: data}
|
|
|
|
n1 := &NodeS10{Data: data}
|
|
|
|
if l.Head == nil {
|
|
|
|
l.Head = n
|
|
|
|
} else {
|
|
|
|
iterator := l.Head
|
|
|
|
for iterator.Next != nil {
|
|
|
|
iterator = iterator.Next
|
|
|
|
}
|
|
|
|
iterator.Next = n
|
|
|
|
}
|
|
|
|
if l1.Head == nil {
|
|
|
|
l1.Head = n1
|
|
|
|
} else {
|
|
|
|
iterator1 := l1.Head
|
|
|
|
for iterator1.Next != nil {
|
|
|
|
iterator1 = iterator1.Next
|
|
|
|
}
|
|
|
|
iterator1.Next = n1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
func comparFuncList10(l *List10, l1 *ListS10, data interface{}) {
|
|
|
|
for l.Head != nil || l1.Head != nil {
|
|
|
|
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n",
|
|
|
|
data, listToStringStu12(l1), correct.ListToString(l.Head), l1.Head, l.Head)
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
}
|
|
|
|
if l.Head.Data != l1.Head.Data {
|
|
|
|
z01.Fatalf("\ndata used: %v\nstudent list:%s\nlist:%s\n\nListRemoveIf() == %v instead of %v\n\n",
|
|
|
|
data, listToStringStu12(l1), correct.ListToString(l.Head), l1.Head.Data, l.Head.Data)
|
|
|
|
}
|
|
|
|
l.Head = l.Head.Next
|
|
|
|
l1.Head = l1.Head.Next
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
// removes all the elements that are equal to a value
|
|
|
|
func main() {
|
|
|
|
link1 := &List10{}
|
|
|
|
link2 := &ListS10{}
|
|
|
|
var index int
|
|
|
|
table := []correct.NodeTest{}
|
|
|
|
|
|
|
|
table = correct.ElementsToTest(table)
|
|
|
|
|
|
|
|
table = append(table,
|
|
|
|
correct.NodeTest{
|
|
|
|
Data: []interface{}{"hello", "hello1", "hello2", "hello3"},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
|
|
|
|
for _, arg := range table {
|
|
|
|
for i := 0; i < len(arg.Data); i++ {
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
listPushBackTest10(link2, link1, arg.Data[i])
|
|
|
|
}
|
|
|
|
aux := len(arg.Data) - 1
|
|
|
|
|
|
|
|
index = z01.RandIntBetween(0, aux)
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
if link1.Head != nil && link2.Head != nil {
|
|
|
|
cho := arg.Data[index]
|
|
|
|
student.ListRemoveIf(link2, cho)
|
|
|
|
correct.ListRemoveIf(link1, cho)
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
comparFuncList10(link1, link2, cho)
|
|
|
|
} else {
|
|
|
|
student.ListRemoveIf(link2, 1)
|
|
|
|
correct.ListRemoveIf(link1, 1)
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
comparFuncList10(link1, link2, 1)
|
|
|
|
}
|
|
|
|
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
link1 = &List10{}
|
|
|
|
link2 = &ListS10{}
|
|
|
|
}
|
|
|
|
}
|