官术网_书友最值得收藏!

  • Go Systems Programming
  • Mihalis Tsoukalos
  • 248字
  • 2021-07-02 18:08:00

Exercises

  1. Browse the Go documentation site: https://golang.org/doc/.
  2. Write a Go program that keeps reading integers until you give the number 0 as input, then it prints the minimum and maximum integer in the input.
  3. Write the same Go program as before, but this time, you will get your input using command-line arguments. Which version do you think is better? Why?
  4. Write a Go program that supports two command-line options (-i and -k) in random order using if statements. Now change your program to support three command-line arguments. As you will see, the complexity of the latter program is just too much to handle using if statements.
  5. If the indices of a map were natural numbers, are there any cases that it would be wise and efficient to use a map instead of an array?
  6. Try to put the functionality of array2map.go into a separate function.
  7. Try to develop your own random number generator in Go that will still use the current time as a seed but not the math/rand package.
  8. Learn how to create a slice from an existing array. What happens when you make changes to the slice?
  9. Use the copy() function to make a copy of an existing slice. What happens when the destination slice is smaller than the source slice? What happens when the destination slice is bigger than the source slice?
  10. Try to write an interface for supporting points in 3D space. Then, use this interface to support points that reside on the x-axis.
主站蜘蛛池模板: 墨玉县| 建瓯市| 桃江县| 台东市| 依安县| 平塘县| 高陵县| 揭阳市| 祁门县| 邓州市| 海宁市| 鹤岗市| 绿春县| 衡阳县| 广州市| 万州区| 广灵县| 越西县| 探索| 小金县| 体育| 山阴县| 玛沁县| 滕州市| 区。| 岳西县| 灵川县| 东城区| 白山市| 桐庐县| 隆回县| 绥滨县| 五大连池市| 高尔夫| 和平区| 磴口县| 安徽省| 鲁山县| 永定县| 积石山| 澄城县|