Slice Exercises
Exercises Level I - Basics — Warm-Up
Let's reinforce your basic knowledge of slices.
Exercises Level II - Appending
Discover the power of the append function.
Exercises Level III - Slicing
Discover the power of slicing.
Exercises Level IV - Internals
Peek into the internals of the slices and gain more insight. This is necessary for complete command of the slices.
Exercises Level V - Advanced Operations
Commonly used and more advanced operations are available to slices. Now, it's time to test yourself and fix some common problems.
★ WARNING ★ Please update your local copy of the prettyslice package for some examples to work. Please find the intructions how to do so here.
-
Practice Advanced Slice Operations
Let's warm you up for the advanced slice operations, and reinforce your neurons.
-
Limit the backing array sharing
Your package needs to control the slices that it shares with the outside world.
-
A slice retrieved from a package causes a memory leak in your program. You need to fix it.
-
Add a newline after each sentence
Use the power of the
copy()
function and add newlines into a new buffer from a string slice. This exercise is more tricky than you might think. -
Group the web request logs into a multi-dimensional slice. Allocate a slice with the exact size needed by doing some wizardary calculations. And lastly, pretty print the result.