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"
|
|
|
|
|
|
|
|
student "student"
|
|
|
|
|
|
|
|
"github.com/01-edu/public/go/tests/func/correct"
|
|
|
|
|
|
|
|
"github.com/01-edu/public/go/tests/lib"
|
|
|
|
)
|
|
|
|
|
|
|
|
type (
|
|
|
|
Node11 = student.NodeL
|
|
|
|
List11 = correct.List
|
|
|
|
NodeS11 = correct.NodeL
|
|
|
|
ListS11 = student.List
|
|
|
|
)
|
|
|
|
|
|
|
|
func listToStringStu(l *ListS11) 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
|
|
|
|
}
|
|
|
|
|
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 listPushBackTest11(l1 *ListS11, l2 *List11, data interface{}) {
|
|
|
|
n1 := &Node11{Data: data}
|
|
|
|
n2 := &NodeS11{Data: data}
|
|
|
|
|
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 l1.Head == nil {
|
|
|
|
l1.Head = n1
|
|
|
|
} else {
|
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
|
|
|
iterator := l1.Head
|
|
|
|
for iterator.Next != nil {
|
|
|
|
iterator = iterator.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
|
|
|
iterator.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
|
|
|
l1.Tail = 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
|
|
|
if l2.Head == nil {
|
|
|
|
l2.Head = n2
|
|
|
|
} else {
|
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
|
|
|
iterator1 := l2.Head
|
|
|
|
for iterator1.Next != nil {
|
|
|
|
iterator1 = iterator1.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
|
|
|
iterator1.Next = n2
|
|
|
|
}
|
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
|
|
|
l2.Tail = n2
|
|
|
|
}
|
|
|
|
|
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 comparFuncList11(l1 *List11, l2 *ListS11) {
|
|
|
|
for l1.Head != nil || l2.Head != nil {
|
|
|
|
if (l1.Head == nil && l2.Head != nil) || (l1.Head != nil && l2.Head == nil) {
|
|
|
|
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListMerge() == %v instead of %v\n\n",
|
|
|
|
listToStringStu(l2), correct.ListToString(l1.Head), l2.Head, l1.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 l1.Head.Data != l2.Head.Data {
|
|
|
|
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListMerge() == %v instead of %v\n\n",
|
|
|
|
listToStringStu(l2), correct.ListToString(l1.Head), l2.Head.Data, l1.Head.Data)
|
|
|
|
}
|
|
|
|
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
|
|
|
l2.Head = l2.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
|
|
|
func main() {
|
|
|
|
link1 := &List11{}
|
|
|
|
linkTest := &List11{}
|
|
|
|
link2 := &ListS11{}
|
|
|
|
link2Test := &ListS11{}
|
|
|
|
|
|
|
|
type nodeTest struct {
|
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
|
|
|
data1 []interface{}
|
|
|
|
data2 []interface{}
|
|
|
|
}
|
|
|
|
table := []nodeTest{}
|
|
|
|
// empty list
|
|
|
|
table = append(table,
|
|
|
|
nodeTest{
|
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
|
|
|
data1: []interface{}{},
|
|
|
|
data2: []interface{}{},
|
|
|
|
})
|
|
|
|
table = append(table,
|
|
|
|
nodeTest{
|
|
|
|
data1: correct.ConvertIntToInterface(lib.MultRandInt()),
|
|
|
|
data2: []interface{}{},
|
|
|
|
})
|
|
|
|
// jut ints
|
|
|
|
for i := 0; i < 3; i++ {
|
|
|
|
val := nodeTest{
|
|
|
|
data1: correct.ConvertIntToInterface(lib.MultRandInt()),
|
|
|
|
data2: correct.ConvertIntToInterface(lib.MultRandInt()),
|
|
|
|
}
|
|
|
|
table = append(table, val)
|
|
|
|
}
|
|
|
|
// just strings
|
|
|
|
for i := 0; i < 2; i++ {
|
|
|
|
val := nodeTest{
|
|
|
|
data1: correct.ConvertIntToStringface(lib.MultRandWords()),
|
|
|
|
data2: correct.ConvertIntToStringface(lib.MultRandWords()),
|
|
|
|
}
|
|
|
|
table = append(table, val)
|
|
|
|
}
|
|
|
|
table = append(table,
|
|
|
|
nodeTest{
|
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
|
|
|
data1: []interface{}{},
|
|
|
|
data2: []interface{}{"a", 1},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
for _, arg := range table {
|
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
|
|
|
for i := 0; i < len(arg.data1); i++ {
|
|
|
|
listPushBackTest11(link2, link1, arg.data1[i])
|
|
|
|
}
|
|
|
|
for i := 0; i < len(arg.data2); i++ {
|
|
|
|
listPushBackTest11(link2Test, linkTest, arg.data2[i])
|
|
|
|
}
|
|
|
|
|
|
|
|
correct.ListMerge(link1, linkTest)
|
|
|
|
student.ListMerge(link2, link2Test)
|
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
|
|
|
comparFuncList11(link1, link2)
|
|
|
|
|
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 = &List11{}
|
|
|
|
linkTest = &List11{}
|
|
|
|
link2 = &ListS11{}
|
|
|
|
link2Test = &ListS11{}
|
|
|
|
}
|
|
|
|
}
|