Source file tour/solutions/slices.go

     1  // Copyright 2012 The Go Authors.  All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // +build ignore
     6  
     7  package main
     8  
     9  import "golang.org/x/tour/pic"
    10  
    11  func Pic(dx, dy int) [][]uint8 {
    12  	p := make([][]uint8, dy)
    13  	for i := range p {
    14  		p[i] = make([]uint8, dx)
    15  	}
    16  
    17  	for y, row := range p {
    18  		for x := range row {
    19  			row[x] = uint8(x * y)
    20  		}
    21  	}
    22  
    23  	return p
    24  }
    25  
    26  func main() {
    27  	pic.Show(Pic)
    28  }
    29  

View as plain text