Skip to content

Instantly share code, notes, and snippets.

@kaipakartik
Created December 25, 2013 00:55
Show Gist options
  • Save kaipakartik/8119237 to your computer and use it in GitHub Desktop.
Save kaipakartik/8119237 to your computer and use it in GitHub Desktop.
Solution to the slices exercise in Go
package main
import "code.google.com/p/go-tour/pic"
func Pic(dx, dy int) [][]uint8 {
y := make([][]uint8, dy)
for i := range y {
y[i] = make([]uint8, dx)
}
y = transform(y)
return y
}
func transform(y [][]uint8) [][]uint8 {
for i := range y {
for j := range y[i] {
y[i][j] = uint8(i + j)
}
}
return y
}
func main() {
pic.Show(Pic)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment