mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:21:38 +08:00
fix: coding style and file format for chapter 7.
This commit is contained in:
@@ -9,5 +9,4 @@ func main() {
|
||||
}
|
||||
fmt.Println(arr) // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14]
|
||||
|
||||
|
||||
}
|
@@ -18,7 +18,7 @@ func main() {
|
||||
fmt.Printf("%v", mapFunc(mf, list))
|
||||
}
|
||||
|
||||
func mapFunc(mf func(int) int, list []int) ([]int) {
|
||||
func mapFunc(mf func(int) int, list []int) []int {
|
||||
result := make([]int, len(list))
|
||||
for ix, v := range list {
|
||||
result[ix] = mf(v)
|
||||
|
@@ -34,6 +34,7 @@ func main() {
|
||||
s := "My Test String!"
|
||||
fmt.Println(s, " --> ", reverse(s))
|
||||
}
|
||||
|
||||
/* Output:
|
||||
The reversed string is -elgooG-
|
||||
The reversed string is -elgooG-
|
||||
|
@@ -12,4 +12,5 @@ func Split2(s string) string {
|
||||
mid := len(s) / 2
|
||||
return s[mid:] + s[:mid]
|
||||
}
|
||||
|
||||
// Output: The string Google transformed is: gleGoo
|
@@ -36,4 +36,3 @@ func SumAndAverage (a []int) (int, float32) {
|
||||
}
|
||||
return sum, float32(sum / len(a))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user