From ed17b12acdcbd2a1c1d7df82418f417d6b6952c3 Mon Sep 17 00:00:00 2001 From: Inanc Gumus Date: Tue, 5 Mar 2019 23:49:54 +0300 Subject: [PATCH] fix: some typos in slices adv. ops. --- .../exercises/22-adv-ops-practice/main.go | 9 +++---- .../main.go | 2 +- .../solution/api/api.go | 1 + .../exercises/24-fix-the-memory-leak/main.go | 4 +-- 16-slices/exercises/25-add-lines/main.go | 23 +++++++++-------- .../exercises/26-print-daily-requests/main.go | 25 +++++++++++-------- 16-slices/exercises/README.md | 2 +- 7 files changed, 36 insertions(+), 30 deletions(-) diff --git a/16-slices/exercises/22-adv-ops-practice/main.go b/16-slices/exercises/22-adv-ops-practice/main.go index 563058e..d9f6f16 100644 --- a/16-slices/exercises/22-adv-ops-practice/main.go +++ b/16-slices/exercises/22-adv-ops-practice/main.go @@ -78,12 +78,11 @@ func main() { // // #4: Copy elements from an array to the `names` slice. // - // Currently, `cap(names)` is 5. So, copy only - // the first two elements of the following array - // to the last two elements of the `names` slice. + // Copy only the first two elements of the following + // array to the last two elements of the `names` slice. // - // Print the names slice (do not forget extending it). - // You should print 5 elements. + // Print the names slice (do not forget extending it + // after appending). You should print 5 elements. // // Observe how the backing array stays the same. // diff --git a/16-slices/exercises/23-limit-the-backing-array-sharing/main.go b/16-slices/exercises/23-limit-the-backing-array-sharing/main.go index 22570f7..1b78c53 100644 --- a/16-slices/exercises/23-limit-the-backing-array-sharing/main.go +++ b/16-slices/exercises/23-limit-the-backing-array-sharing/main.go @@ -48,7 +48,7 @@ import ( // EXPECTED OUTPUT // // Now the program cannot change the API's original backing array -// (beyond the returned capacity) (so the api now owns the control) +// (beyond the returned capacity) (so the api now owns the control) // ^ ^ // | | // API's readings: [5 10 3 25 45 80 90] diff --git a/16-slices/exercises/23-limit-the-backing-array-sharing/solution/api/api.go b/16-slices/exercises/23-limit-the-backing-array-sharing/solution/api/api.go index 91ef119..8ed8e2c 100644 --- a/16-slices/exercises/23-limit-the-backing-array-sharing/solution/api/api.go +++ b/16-slices/exercises/23-limit-the-backing-array-sharing/solution/api/api.go @@ -5,6 +5,7 @@ var temps = []int{5, 10, 3, 25, 45, 80, 90} // Read returns a range of temperature readings beginning from // the `start` until to the `stop`. func Read(start, stop int) []int { + // // Uses a full slice expression to control the length of the // backing array (or the capacity of the returned slice). // diff --git a/16-slices/exercises/24-fix-the-memory-leak/main.go b/16-slices/exercises/24-fix-the-memory-leak/main.go index d763679..92cdbf7 100644 --- a/16-slices/exercises/24-fix-the-memory-leak/main.go +++ b/16-slices/exercises/24-fix-the-memory-leak/main.go @@ -17,7 +17,7 @@ import ( // --------------------------------------------------------- // EXERCISE: Fix the memory leak // -// You're receiving millions of temperature data points from +// You receive millions of temperature data points from // an API, but you only need the last 10 data points. // // Currently, there is a memory leak in your program. @@ -33,7 +33,7 @@ import ( // EXPECTED OUTPUT EXPLANATION // // Your output will be different. Your goal is to reduce the -// difference between the two measurements of the memory usage. +// difference between two measurements of the memory usage. // // For the expected output above: // diff --git a/16-slices/exercises/25-add-lines/main.go b/16-slices/exercises/25-add-lines/main.go index a6188c2..01a677d 100644 --- a/16-slices/exercises/25-add-lines/main.go +++ b/16-slices/exercises/25-add-lines/main.go @@ -15,9 +15,9 @@ import ( // each sentence of the lyric to the new buffer, then // after each sentence adding a newline character. // -// You cannot guess how many times you will get across -// something like this. Believe me, learning this will -// make you a better Gopher. +// You will get across something like this all the time +// in your gopher life. Believe me, learning how to +// solve this exercise will make you a better hopher. // // // RESTRICTIONS @@ -26,14 +26,14 @@ import ( // // . Instead, only use the `copy()` func. // -// . You cannot use slicing for printing the sentences. +// . Don't use slicing for printing the sentences. // -// . Instead, use slicing to fill the new buffer, then print it. +// . Instead, use slicing for filling the new buffer. // // // STEPS // -// . Follow the instructions inside the code. +// . Please follow the instructions inside the code. // // // EXPECTED OUTPUT @@ -51,7 +51,7 @@ func main() { // This inits some options for the prettyslice package. // You can change the options if you want. // - // s.Colors(false) // if your editor is light colored then enable this + // s.Colors(false) // if your editor is light background color then enable this s.PrintBacking = true // prints the backing arrays s.MaxPerLine = 15 // prints max 15 elements per line s.SpaceCharacter = "*" // print this instead of printing a newline (for debugging) @@ -65,10 +65,10 @@ func main() { // // RESTRICTION EXPLANATION: // - // Don't do something like this: - // (Do not use slicing for printing the sentences) + // Do not use slicing for printing the sentences. + // + // For example, don't do something like this: // - // fmt.Println(lyric[:8]) // fmt.Println(lyric[8:18]) // fmt.Println(lyric[18:23]) @@ -77,7 +77,8 @@ func main() { // // #1: CREATE A LARGE ENOUGH BUFFER (A NEW SLICE) // - // You need to put each lyric sentence + a newline into this buffer + // You need to put each lyric sentence + // + a newline character into this buffer // // I name the buffer: `fix`, you can name it however you want diff --git a/16-slices/exercises/26-print-daily-requests/main.go b/16-slices/exercises/26-print-daily-requests/main.go index b608b1b..c230d72 100644 --- a/16-slices/exercises/26-print-daily-requests/main.go +++ b/16-slices/exercises/26-print-daily-requests/main.go @@ -4,10 +4,10 @@ package main // EXERCISE: Print daily requests // // You've got a requests log for a system in a slice: `reqs`. -// The log contains the total requests counts per 8 hours. +// The log contains the total request counts per 8 hours. // // The reqs slice is a single-dimensional slice but you need -// to group the daily into a slice named: `daily`. +// to group the requests daily into a slice named: `daily`. // // Please follow the instructions inside the code to solve // the exercise. @@ -40,11 +40,16 @@ func main() { // // reqs := []int{ - // 500, 600, 250, - // 200, 400, 50, - // 900, 800, 600, - // 750, 250, 100, - // 100, 150, + // // 1st day + // 500, 600, 250, + // // 2nd day + // 200, 400, 50, + // // 3rd day + // 900, 800, 600, + // // 4th day + // 750, 250, 100, + // // last day + // 100, 150, // } // @@ -93,12 +98,12 @@ func main() { // // ❤️ NOTE ❤️ // - // If you could't solve this challenge. Please do not get discouraged. + // If you could't solve this challenge, please do not get discouraged. // // Look at the solution, then try to solve it again. This is valuable too. // - // Then ️change the request data, the number of requests per day (now it's 3), etc - // and then try to solve it again. + // Then ️change the request data, the number of requests per day (now it's 3), + // etc., and then try to solve it again. // // ------------------------------------------------------------------------ } diff --git a/16-slices/exercises/README.md b/16-slices/exercises/README.md index 3fa6bf5..ecf7bca 100644 --- a/16-slices/exercises/README.md +++ b/16-slices/exercises/README.md @@ -79,7 +79,7 @@ Commonly used and more advanced operations are available to slices. Now, it's ti Your API does not control the slices that it share with the outside world. You need to fix it. -3. **[Fix the Memory Leak](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/25-fix-the-memory-leak)** +3. **[Fix the Memory Leak](https://github.com/inancgumus/learngo/tree/master/16-slices/exercises/24-fix-the-memory-leak)** A slice retrieved from an API causes a memory leak in your program. You need to fix it.