Skip to content

Instantly share code, notes, and snippets.

@marcesher
Created December 29, 2013 13:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marcesher/8170295 to your computer and use it in GitHub Desktop.
Save marcesher/8170295 to your computer and use it in GitHub Desktop.
simple solution to Go tour slide 35, exercise on slices. This prints a blue gradient
package main
import (
"code.google.com/p/go-tour/pic"
"math"
)
func Pic(dx, dy int) [][]uint8 {
p := make([][] uint8, dy)
for i :=0; i < dy; i++ {
p[i] = make([] uint8, dx)
}
for i :=0; i < dy; i++ {
for z :=0; z < dx; z++ {
p[i][z] = uint8(math.Nextafter(float64(i), float64(z)))
}
}
return p
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment