Skip to content

Instantly share code, notes, and snippets.

@stamler
Created August 6, 2013 18:58
Show Gist options
  • Save stamler/6167518 to your computer and use it in GitHub Desktop.
Save stamler/6167518 to your computer and use it in GitHub Desktop.
Exercise 35 (Slices) from tour.golang.org
package main
import "code.google.com/p/go-tour/pic"
// #35 Slices Exercise
func Pic(dx, dy int) [][]uint8 {
result := make([][]uint8, dy)
for i := range result {
result[i] = make([]uint8, dx)
for j := range result[i] {
result[i][j] = uint8((i + j) / 2)
}
}
return result
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment