開発環境
- macOS High Sierra - Apple (OS)
- Emacs (Text Editor)
- Go (プログラミング言語)
Introducing Go: Build Reliable, Scalable Programs (Caleb Doxsey (著)、O'Reilly Media)のChapter 6.(Functions)、Exercises(No. 1101)2.を取り組んでみる。
コード(Emacs)
package main
import "fmt"
func half(n int) (int, bool) {
return n / 2, n%2 == 0
}
func main() {
for i := 1; i <= 10; i += 1 {
a, b := half(i)
fmt.Println(i, a, b)
}
}
入出力結果(Terminal)
$ go run sample2.go 1 0 false 2 1 true 3 1 false 4 2 true 5 2 false 6 3 true 7 3 false 8 4 true 9 4 false 10 5 true $
0 コメント:
コメントを投稿