開発環境
- macOS High Sierra - Apple (OS)
- Emacs (Text Editor)
- Go (プログラミング言語)
Introducing Go: Build Reliable, Scalable Programs (Caleb Doxsey (著)、O'Reilly Media)のChapter 5.(Arrays, Slices, and Maps)、Exercises(No. 854)2、3、4.を取り組んでみる。
コード(Emacs)
package main import "fmt" func main() { fmt.Println("2.") s := make([]int, 3, 9) fmt.Println(s, len(s) == 3) fmt.Println("3.") x := [6]string{"a", "b", "c", "d", "e", "f"} // [c, d, e] fmt.Println(x[2:5]) fmt.Println("4.") z := []int{ 48, 96, 86, 68, 57, 82, 63, 70, 37, 34, 83, 27, 19, 97, 9, 17, } smallest := z[0] for _, n := range z { if n < smallest { smallest = n } } fmt.Println(smallest) }
入出力結果(Terminal)
$ go run sample2.go 2. [0 0 0] true 3. [c d e] 4. 9 $
0 コメント:
コメントを投稿