TRIVIAL go fmt

cat-town
Dan Buch 12 years ago
parent 090d101d51
commit 736d61e82c

@ -2,8 +2,8 @@ package main
import ( import (
"fmt" "fmt"
"time"
"math" "math"
"time"
) )
func sum(a []int, c chan int) { func sum(a []int, c chan int) {
@ -11,7 +11,7 @@ func sum(a []int, c chan int) {
for _, v := range a { for _, v := range a {
sum += v sum += v
} }
to_sleep := time.Duration(100 * math.Abs(float64(sum))) * time.Millisecond to_sleep := time.Duration(100*math.Abs(float64(sum))) * time.Millisecond
fmt.Printf("Sleeping %s...\n", to_sleep) fmt.Printf("Sleeping %s...\n", to_sleep)
time.Sleep(to_sleep) time.Sleep(to_sleep)
c <- sum c <- sum
@ -27,5 +27,5 @@ func main() {
fmt.Printf("x = %d\n", x) fmt.Printf("x = %d\n", x)
y := <-c y := <-c
fmt.Printf("y = %d\n", y) fmt.Printf("y = %d\n", y)
fmt.Println(x, y, x + y) fmt.Println(x, y, x+y)
} }

@ -1,8 +1,8 @@
package main package main
import ( import (
"strings"
"code.google.com/p/go-tour/wc" "code.google.com/p/go-tour/wc"
"strings"
) )
func WordCount(s string) map[string]int { func WordCount(s string) map[string]int {

@ -9,7 +9,7 @@ func Pic(dx, dy int) [][]uint8 {
for i := range cols { for i := range cols {
cols[i] = make([]uint8, dx) cols[i] = make([]uint8, dx)
for j := range cols[i] { for j := range cols[i] {
cols[i][j] = uint8(j^i) cols[i][j] = uint8(j ^ i)
} }
} }
return cols return cols

@ -8,7 +8,7 @@ import (
// using Newton's method // using Newton's method
func Sqrt(x float64) float64 { func Sqrt(x float64) float64 {
z := x - (x * 0.1) z := x - (x * 0.1)
for i := 0 ; i < 1000 ; i++ { for i := 0; i < 1000; i++ {
newZ := z - (((z * z) - x) / 2 * z) newZ := z - (((z * z) - x) / 2 * z)
diff := math.Abs(newZ) - math.Abs(z) diff := math.Abs(newZ) - math.Abs(z)
if math.Abs(diff) < 0.01 { if math.Abs(diff) < 0.01 {

Loading…
Cancel
Save