Skip to content

Instantly share code, notes, and snippets.

@eranation
Created May 23, 2013 19:39
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 eranation/5638840 to your computer and use it in GitHub Desktop.
Save eranation/5638840 to your computer and use it in GitHub Desktop.
Solution to the slices exercise at http://tour.golang.org/#35
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
ys := make([][]uint8, dy)
for y := range ys {
xs := make([]uint8, dx)
ys[y] = xs
for x:= range xs {
xs[x] = uint8(x * y)
}
}
return ys
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment