The zipper data structure
pub enum MList[T] {
Nil
Cons(T, MList[T])
}
pub struct Zipper[T] {
left : MList[T] // elements left of focus, reversed
focus : T // current element in focus
right : MList[T] // elements right of focus
}let list = MList::from_array([1, 2, 3, 4])
let zipper = from_list(list).unwrap().move_right().unwrap() // focus on 2
let at_end = zipper.move_to_end() // focus on 4
let at_start = at_end.move_to_start() // focus on 1
let result = at_start.to_list() // [1, 2, 3, 4]The zipper data structure