go-learning/exercises/slices.go

25 lines
408 B
Go
Raw Permalink Normal View History

2023-07-12 16:45:14 +03:00
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)
}