As a magician-to-be, Elyse needs to practice some basics. She has a stack of cards that she wants to manipulate.
To make things a bit easier she only uses the cards 1 to 10.
Return the card at position index
from the given stack.
GetItem([]uint8{1, 2, 4, 1}, 2)
// Output: 4
Exchange the card at position index
with the new card provided and return the adjusted stack.
Note that this will also change the input slice which is ok.
index := 2
new_card := 6
SetItem([]uint8{1, 2, 4, 1}, index, new_card)
// Output: []uint8{1, 2, 6, 1}
Create a stack of given length
and fill it with cards of the given value
.
PrefilledSlice(8, 3)
// Output: []int{8, 8, 8}
Remove the card at position index
from the stack and return the stack.
RemoveItem([]int{3, 2, 6, 4, 8}, 2)
// Output: []int{3, 2, 4, 8}