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 Node3 = student.NodeL
|
|
|
|
type List3 = correct.List
|
|
|
|
type NodeS3 = correct.NodeL
|
|
|
|
type ListS3 = student.List
|
|
|
|
|
|
|
|
func listToStringStu9(l *ListS3) 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
|
|
|
// inserts node on two lists
|
|
|
|
func listPushBackTest3(l *ListS3, l1 *List3, data interface{}) {
|
|
|
|
n := &Node3{Data: data}
|
|
|
|
n1 := &NodeS3{Data: data}
|
|
|
|
if l.Head == nil {
|
|
|
|
l.Head = n
|
|
|
|
l.Tail = n
|
|
|
|
} else {
|
|
|
|
l.Tail.Next = n
|
|
|
|
l.Tail = n
|
|
|
|
}
|
|
|
|
if l1.Head == nil {
|
|
|
|
l1.Head = n1
|
|
|
|
l1.Tail = n1
|
|
|
|
} else {
|
|
|
|
l1.Tail.Next = n1
|
|
|
|
l1.Tail = n1
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// last element of the correct.ListS
|
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 := &List3{}
|
|
|
|
link2 := &ListS3{}
|
|
|
|
table := []correct.NodeTest{}
|
|
|
|
|
|
|
|
table = correct.ElementsToTest(table)
|
|
|
|
table = append(table,
|
|
|
|
correct.NodeTest{
|
|
|
|
Data: []interface{}{3, 2, 1},
|
|
|
|
},
|
|
|
|
)
|
|
|
|
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
|
|
|
listPushBackTest3(link2, link1, arg.Data[i])
|
|
|
|
}
|
|
|
|
aux1 := correct.ListLast(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
|
|
|
aux2 := student.ListLast(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
|
|
|
if aux1 != aux2 {
|
|
|
|
z01.Fatalf("\nlist:%s\n\nListLast() == %v instead of %v\n\n",
|
|
|
|
listToStringStu9(link2), aux2, aux1)
|
|
|
|
}
|
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 = &List3{}
|
|
|
|
link2 = &ListS3{}
|
|
|
|
}
|
|
|
|
}
|