LoginSignup
11
8

More than 5 years have passed since last update.

A Tour of Go Exercise: Slices

Last updated at Posted at 2014-07-20

Exercise: Slices

package main

import "code.google.com/p/go-tour/pic"

func Pic(dx, dy int) [][]uint8 {
    ret := make([][]uint8, dy);
    for y := 0; y < dy; y++ {
        ret[y] = make([]uint8, dx);
        for x := 0; x < dx; x++ {
            //ret[y][x] = uint8(x^y);
            //ret[y][x] = uint8(x+y)/2;
            //ret[y][x] = uint8(x*y);
            //ret[y][x] = uint8((x^y)+(x+y)/2)
            ret[y][x] = uint8((x^y)*(x+y)/2)
        }
    }
    return ret
}

func main() {
    pic.Show(Pic)
}

go言語のsliceを理解しよう

Go Slices: usage and internals

goのスライスの内部実装

Goプログラミング言語仕様

Go by Example: Slices

11
8
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
8