update: slice exercise 21

This commit is contained in:
Inanc Gumus
2019-08-23 00:33:53 +03:00
parent 312fbbf5a4
commit cfc6f5fbfa

View File

@ -23,13 +23,23 @@ import (
// //
// STEPS // STEPS
// //
// INITIAL SLICE:
// [all my troubles seemed so far away oh i believe in yesterday now it looks as though they are here to stay]
//
//
// 1. Prepend "yesterday" to the `lyric` slice. // 1. Prepend "yesterday" to the `lyric` slice.
// //
// RESULT SHOULD BE:
// [yesterday all my troubles seemed so far away oh i believe in yesterday now it looks as though they are here to stay]
//
//
// 2. Put the words to the correct positions in the `lyric` slice. // 2. Put the words to the correct positions in the `lyric` slice.
// //
// 3. Print the `lyric` slice. // RESULT SHOULD BE:
// [yesterday all my troubles seemed so far away now it looks as though they are here to stay oh i believe in yesterday]
// //
// HINT: You don't need use the "yesterday" word from the `lyric` slice. //
// 3. Print the `lyric` slice.
// //
// //
// BONUS // BONUS
@ -38,6 +48,22 @@ import (
// //
// + Check whether your conclusions are correct. // + Check whether your conclusions are correct.
// //
//
// HINTS
//
// Only look at this if you get stuck.
//
// You can use the following slice operations to solve the exercise.
//
// + Prepends "value" to the slice:
// slice = append([]string{"value"}, slice...)
//
// + Appends some part (N to M) of the same slice to itself:
// slice = append(slice, slice[N:M]...)
//
// + Copies the last part of the slice starting from M to the first part of the slice until N:
// slice = append(slice[:N], slice[M:]...)
//
// --------------------------------------------------------- // ---------------------------------------------------------
func main() { func main() {