Created
February 16, 2023 12:22
-
-
Save leobeeson/96954cc37255559c004d1a02774d14aa to your computer and use it in GitHub Desktop.
Solution to `Slices Exercise` in `A Tour of Go` tutorial.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import "golang.org/x/tour/pic" | |
func Pic(dx, dy int) [][]uint8 { | |
canvas := make([][]uint8, dy) | |
for y := 0; y < dy; y ++ { | |
canvas[y] = make([]uint8, dx) | |
} | |
for y := 0; y < dy; y ++ { | |
for x := 0; x < dx; x ++ { | |
canvas[y][x] = uint8(x) * uint8(y) | |
} | |
} | |
return canvas | |
} | |
func main() { | |
pic.Show(Pic) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment