update: slice exercises 23

This commit is contained in:
Inanc Gumus
2019-08-22 20:00:58 +03:00
parent ce5a32ecbe
commit 792a7a75d4
4 changed files with 38 additions and 65 deletions

View File

@ -1,32 +1,21 @@
package api
// note: "client" means the users or importers of your package.
// The original temperatures slice.
var temps = []int{5, 10, 3, 25, 45, 80, 90}
// ^ ^ ^ ^ ^
// | | | +-----------+
// the client is allowed to |
// change these elements. |
// |
// but the client shouldn't change the
// rest of the elements after the 3rd element.
// Read returns a range of temperature readings beginning from
// the `start` until to the `stop`.
// Read returns a slice of elements from the temps slice.
func Read(start, stop int) []int {
// ----------------------------------------
// RESTRICTIONS — ONLY ADD YOUR CODE HERE
// RESTRICTIONS — ONLY ADD YOUR CODE IN THIS AREA
// returns a slice from the temps slice to the client.
portion := temps[start:stop]
// RESTRICTIONS — ONLY ADD YOUR CODE IN THIS AREA
// ----------------------------------------
return portion
}
// All returns all the temperature readings
// All returns the temps slice
func All() []int {
return temps
}