From d23bfcc86998431aa667dfa1a05122549341bd09 Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Sat, 25 Aug 2012 23:08:27 -0400 Subject: [PATCH] Slice exercise with the blue and white picture! --- gotime/src/exercise-slices.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 gotime/src/exercise-slices.go diff --git a/gotime/src/exercise-slices.go b/gotime/src/exercise-slices.go new file mode 100644 index 0000000..111ef15 --- /dev/null +++ b/gotime/src/exercise-slices.go @@ -0,0 +1,20 @@ +package main + +import ( + "code.google.com/p/go-tour/pic" +) + +func Pic(dx, dy int) [][]uint8 { + cols := make([][]uint8, dy) + for i := range cols { + cols[i] = make([]uint8, dx) + for j := range cols[i] { + cols[i][j] = uint8(j^i) + } + } + return cols +} + +func main() { + pic.Show(Pic) +}