Skip to content

Instantly share code, notes, and snippets.

@sivan
Created December 3, 2019 18:03
Show Gist options
  • Save sivan/7f9f9affbbece62d63b23b5c99d61b7c to your computer and use it in GitHub Desktop.
Save sivan/7f9f9affbbece62d63b23b5c99d61b7c to your computer and use it in GitHub Desktop.
Go Exercise: Slices
package main
import (
"fmt"
"golang.org/x/tour/pic"
)
func Pic(dx, dy int) [][]uint8 {
p := make([][]uint8, dy)
for y := range p {
px := make([]uint8, dx)
for x := range px {
px[x] = uint8(x * y - 1)
}
p[y] = px
}
fmt.Println(p)
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