Problem 18
(Intermediate 🌟🌟) Given two indices, i
and k
, the slice is the list containing the elements between the i'th and k'th element of the original list (both limits included). Start counting the elements with 1.
variable {α : Type}
def slice (l : List α) (i k : Nat) : List α :=
sorry
-- The following codes are for test and you should not edit these.
example : slice [1, 2, 3, 4, 5, 6, 7, 8, 9] 3 7 = [3, 4, 5, 6, 7] := by rfl
example : slice [1, 2, 3, 4, 5] 1 1 = [1] := by rfl
example : slice [1, 2, 3, 4, 5] 2 3 = [2, 3] := by rfl