ITADN

List Zipper

#86Pull RequestPolqt 创建于 2025-04-17已合并
P
Polqtcommented
The List Zipper is a data structure derived from functional programming principles. It represents a sequence (list) along with a specific point of focus, conceptually dividing the list into elements before the focus and elements at and after the focus. This structure facilitates efficient, localized, immutable modifications and traversal around the focus point. Typically, the 'before' part is stored in reverse to optimize operations near the focus. ## Task Your task is to implement a generic List Zipper in Go. This structure should provide capabilities for creation, navigation (moving the focus), inspection (getting the focused value), modification (insertion/deletion near the focus), and conversion back to a standard list. Adherence to the principle of immutability is crucial – operations that modify the zipper must return a *ew zipper instance, leaving the original unchanged. Note that it must contain fields to represent the elements before the focus (`left`, reversed) and the elements at/after the focus (`right`).
合并状态:已合并 合并于 2025-07-30 关闭于 2025-07-30 4 条评论