index work
This commit is contained in:
parent
64aa4acf05
commit
3474d39dc5
@ -1,16 +0,0 @@
|
|||||||
// ## Mutation
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
var x string
|
|
||||||
x = "old"
|
|
||||||
fmt.Println(x)
|
|
||||||
|
|
||||||
// You can mutate variables in Go by re-assigning the
|
|
||||||
// variable to a new value.
|
|
||||||
x = "new"
|
|
||||||
fmt.Println(x)
|
|
||||||
}
|
|
@ -1,3 +0,0 @@
|
|||||||
$ go run mutation.go
|
|
||||||
old
|
|
||||||
new
|
|
@ -1,20 +0,0 @@
|
|||||||
// ## Sum
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
var x [5]float64
|
|
||||||
x[0] = 98
|
|
||||||
x[1] = 93
|
|
||||||
x[2] = 77
|
|
||||||
x[3] = 82
|
|
||||||
x[4] = 83
|
|
||||||
|
|
||||||
var total float64 = 0
|
|
||||||
for i := 0; i < 5; i++ {
|
|
||||||
total += x[i]
|
|
||||||
}
|
|
||||||
fmt.Println(total / float64(len(x)))
|
|
||||||
}
|
|
@ -1,14 +0,0 @@
|
|||||||
// ## Floats
|
|
||||||
|
|
||||||
package main
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
func main() {
|
|
||||||
x := [5]float64{ 98, 93, 77, 82, 83 }
|
|
||||||
total := 0.0
|
|
||||||
for _, v := range x {
|
|
||||||
total += v
|
|
||||||
}
|
|
||||||
fmt.Println(total / float64(len(x)))
|
|
||||||
}
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user