go-learning/exercises/slices.go

24 lines
408 B
Go

package main
// exercise link: https://go.dev/tour/moretypes/18
import (
// "golang.org/x/tour/pic" // not valid on local!
)
func Pic(dx, dy int) [][]uint8 {
mypic := make([][]uint8, dx)
for i := range mypic {
mypic[i] = make([]uint8, dy)
}
for i, _ := range mypic {
for j, _ := range mypic[i] {
mypic[i][j] = uint8((i*dy + j*3) % 256)
}
}
return mypic
}
func main() {
// pic.Show(Pic)
}