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
|
|
|
|
|
|
|
"./correct"
|
|
|
|
"./student"
|
|
|
|
"github.com/01-edu/public/go/lib"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Node6 = student.NodeL
|
|
|
|
type List6 = correct.List
|
|
|
|
type NodeS6 = correct.NodeL
|
|
|
|
type ListS6 = student.List
|
|
|
|
|
|
|
|
func listToStringStu13(l *ListS6) 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 comparFuncList6(l *List6, l1 *ListS6) {
|
|
|
|
for l.Head != nil || l1.Head != nil {
|
|
|
|
if (l.Head == nil && l1.Head != nil) || (l.Head != nil && l1.Head == nil) {
|
|
|
|
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListReverse() == %v instead of %v\n\n",
|
|
|
|
listToStringStu13(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 {
|
|
|
|
lib.Fatalf("\nstudent list:%s\nlist:%s\n\nListReverse() == %v instead of %v\n\n",
|
|
|
|
listToStringStu13(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
|
|
|
|
|
|
|
func listPushBackTest6(l *ListS6, l1 *List6, data interface{}) {
|
|
|
|
n := &Node6{Data: data}
|
|
|
|
n1 := &NodeS6{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 main() {
|
|
|
|
link1 := &List6{}
|
|
|
|
link2 := &ListS6{}
|
|
|
|
table := []correct.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
|
|
|
Data: []interface{}{"I", 1, "something", 2},
|
|
|
|
}}
|
|
|
|
table = correct.ElementsToTest(table)
|
|
|
|
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 _, item := range arg.Data {
|
|
|
|
listPushBackTest6(link2, link1, item)
|
|
|
|
}
|
|
|
|
student.ListReverse(link2)
|
|
|
|
correct.ListReverse(link1)
|
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
|
|
|
comparFuncList6(link1, link2)
|
|
|
|
link1 = &List6{}
|
|
|
|
link2 = &ListS6{}
|
|
|
|
}
|
|
|
|
}
|