|
|
|
## reverserange
|
|
|
|
|
|
|
|
### Instructions
|
|
|
|
|
|
|
|
Write a program which must:
|
|
|
|
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
- **Allocate (with `make`)** a slice of integers.
|
|
|
|
|
|
|
|
- Fill it with consecutive values that begins at the second argument and end at the first argument (Including the values of thoses arguments !).
|
|
|
|
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
- That prints the slice.
|
|
|
|
|
|
|
|
Errors should be handled.
|
|
|
|
|
Refactor & Beautify & destruction commit
return early, remove else branches, reorder conditions and top-level functions, remove empty lines, remove unnecessary append(), fix typos, stop using testing package, remove dead code, fix mistakes in subjects, tests and solutions, remove disclaimers, reformat comments, simplify solutions, tests, add more instructions to subjects, remove obsolete files, etc.
Some of the reasons behind those modifications will be added to good-practices.en.md
Some of the exercises are now broken, they will have to be fixed, most of them have a "TODO:" comment.
5 years ago
|
|
|
If the number of arguments is different from 2 the program prints nothing.
|
|
|
|
|
|
|
|
### Usage :
|
|
|
|
|
|
|
|
```console
|
|
|
|
student@ubuntu:~/reverserange$ go build
|
|
|
|
student@ubuntu:~/reverserange$ ./reverserange 1 3
|
|
|
|
[3 2 1]
|
|
|
|
student@ubuntu:~/reverserange$ ./reverserange -1 2 | cat -e
|
|
|
|
[2 1 0 -1]$
|
|
|
|
student@ubuntu:~/reverserange$ ./reverserange 0 0
|
|
|
|
[0]
|
|
|
|
student@ubuntu:~/reverserange$ ./reverserange 0 -3
|
|
|
|
[-3 -2 -1 0]
|
|
|
|
student@ubuntu:~/reverserange$ ./reverserange 0 nan | cat -e
|
|
|
|
strconv.Atoi: parsing "nan": invalid syntax$
|
|
|
|
student@ubuntu:~/reverserange$
|
|
|
|
```
|