Renamed to staeter/ziplist. It is published under that name, and new versions come out there.
Versions published as STTR13/ziplist still install under that name. 3 versions of 7 come from the new location (see their notes). 4 versions could not be recovered and cannot be installed.
Unavailable. Nobody can download this version any more, with elm or with the Lamdera compiler: github.com/staeter/ziplist exists but has no tag 1.2.0; Software Heritage not asked yet (this run's --swh-calls were used up); no fork with tag 1.2.0 found (60 same-name repos checked); no cached copy. Use another version.
A ZipList is a list that has a single selected element. We call it current as "the one that is currently selected".
To get more explicit examples, I'm gona represent ZipLists as Lists that have the selected element between "<...>":
Zipper [] 0 [1, 2, 3, 4] == [<0>, 1, 2, 3, 4]
Zipper [2, 1, 0] 3 [4] == [0, 1, 2, <3>, 4]This pseudocode will make the documentation way more enjoyable.
Craft a new ZipList out of a List and an element.
new "a" ["b", "c"] == [<"a">, "b", "c"]Craft a new ZipList out of a List. Current is the first element of the List. Return Nothing if an empty list is given.
Create a new ZipList with a single element in it.
current (singleton "my element") == "my element"
length (singleton "my element") == 1Convert a ZipList into a List.
toList ["a", <"b">, "c"] == ["a", "b", "c"]Return a ZipList length.
length [0, 1, <2>, 3, 4] == 5
length [<0>, 1, 2] == 3Return the index (starting at zero) of the current element.
currentIndex [0, 1, <2>, 3, 4] == Just 2
currentIndex [<0>, 1, 2] == Just 0Test wether current passes a condition.
isCurren odd [0, <1>, 2] == True
isCurren odd [0, <5>, 2] == FalseTest wether the first element of the ZipList passes a condition.
isFirst odd [1, <1>, 2] == True
isFirst odd [4, <5>, 2] == FalseTest wether the last element of the ZipList passes a condition.
isLast odd [1, <1>, 3] == True
isLast odd [4, <5>, 2] == FalseRemove current from a ZipList. The new current is in priority the ZipList's next element.
remove [0, 1, <2>, 3, 4] == Just [0, 1, <3>, 4]
remove [0, 1, <2>] == Just [0, <1>]
remove [<"hello!">] == NothingReplace current from a ZipList with a new value.
replace 9 [0, 1, <2>, 3, 4] == [0, 1, <9>, 3, 4]
replace 9 [0, 1, <2>] == [0, 1, <9>]Insert a new value in a ZipList. The current will be pushed backward to let the new value take its place.
insert 9 [0, 1, <2>, 3, 4] == [0, 1, 2, <9>, 3, 4]
insert 9 [0, 1, <2>] == [0, 1, 2, <9>]Insert a new value in a ZipList right after current.
insertAfter 9 [0, 1, <2>, 3, 4] == [0, 1, <2>, 9, 3, 4]
insertAfter 9 [0, 1, <2>] == [0, 1, <2>, 9]Insert a new value in a ZipList right before current.
insertBefore 9 [0, 1, <2>, 3, 4] == [0, 1, 9, <2>, 3, 4]Keep elements that satisfy the test.
filter ((!=) 3) [0, 3, 3, 1, 3, <2>, 3, 4] == Just [0, 1, <2>, 4]
filter ((!=) 2) [0, 1, <2>, 3, 4] == Just [0, 1, <3>, 4]
filter ((!=) 4) [0, 1, 2, 3, <4>] == Just [0, 1, 2, <3>]
filter ((!=) 4) [4, <4>, 4, 4] == NothingMove current forward. Current will not move if it is at the end of the ZipList.
forward [0, 1, <2>, 3, 4] == [0, 1, 2, <3>, 4]
forward [0, 1, <2>] == [0, 1, <2>]Move current backward. Current will not move if it is at the begining of the ZipList.
backward [0, 1, <2>, 3, 4] == [0, <1>, 2, 3, 4]
backward [<0>, 1, 2] == [<0>, 1, 2]Move current forward a given amout of times. Current will be the last element of the ZipList if the jump size is too big.
jumpForward 2 [0, <1>, 2, 3, 4] == [0, 1, 2, <3>, 4]
jumpForward 2 [0, <1>, 2] == [0, 1, <2>]Move current backward a given amout of times. Current will be the first element of the ZipList if the jump size is too big.
jumpBackward 2 [0, 1, 2, <3>, 4] == [0, <1>, 2, 3, 4]
jumpBackward 2 [0, <1>, 2] == [<0>, 1, 2]Move current forward a given amout of times. Return Nothing if the jump size is too big.
maybeJumpForward 2 [0, <1>, 2, 3, 4] == Just [0, 1, 2, <3>, 4]
maybeJumpForward 2 [0, <1>, 2] == NothingMove current backward a given amout of times. Return Nothing if the jump size is too big.
maybeJumpBackward 2 [0, 1, 2, <3>, 4] == Just [0, <1>, 2, 3, 4]
maybeJumpBackward 2 [0, <1>, 2] == NothingMove current to index 0.
goToStart [0, 1, 2, 3, <4>] == [<0>, 1, 2, 3, 4]
goToStart [<0>, 1, 2] == [<0>, 1, 2]
goToStart [0, <1>, 2] == [<0>, 1, 2]Move current to the end of the ZipList.
goToEnd [0, 1, 2, 3, <4>] == [0, 1, 2, 3, <4>]
goToEnd [<0>, 1, 2] == [0, 1, <2>]
goToEnd [0, <1>, 2] == [0, 1, <2>]Move current to an index (starting at zero). Return Nothing if the index is too low and it will be the last element if the index is too high.
goToIndex 2 [0, 1, 2, 3, <4>] == Just [0, 1, <2>, 3, 4]
goToIndex 5 [0, <1>, 2] == Nothing
goToIndex 1 [0, <1>, 2] == Just [0, <1>, 2]Move current to the first element of a ZipList fulfilling a condition. Return Nothing if no matching element.
goToFirst isEven [8, 1, 2, 3, <4>] == Just [<8>, 1, 2, 3, 4]
goToFirst isEven [5, <1>, 2] == Just [5, 1, <2>]
goToFirst isEven [1, <1>, 7] == NothingMove current to the next element fulfilling a condition. Return Nothing if there is no matching element after current.
goToNext isEven [0, 1, <2>, 3, 4] == Just [0, 1, 2, 3, <4>]
goToNext isEven [8, 2, <1>, 3, 7] == Nothing
goToNext isEven [5, <1>, 2, 3] == Just [5, 1, <2>, 3]Move current to the last element of a ZipList fulfilling a condition. Return Nothing if there is no matching element.
goToLast isOdd [0, 1, <2>, 3, 4] == Just [0, 1, 2, <3>, 4]
goToLast isOdd [8, 2, <1>, 3, 7] == Just [8, 2, 1, 3, <7>]
goToLast isOdd [2, <4>, 6, 8] == NothingMove current to the previous element fulfilling a condition. Return Nothing if there is no matching element before current.
goToPrevious isOdd [0, 1, <2>, 3, 4] == Just [0, <1>, 2, 3, 4]
goToPrevious isOdd [8, 2, 1, 4, <7>] == Just [8, 2, <1>, 4, 7]
goToPrevious isOdd [2, <4>, 3, 5] == NothingApply a function to every element of a ZipList.
map String.fromInt [0, 1, <2>, 3, 4] == ["0", "1", <"2">, "3", "4"]
map String.fromInt [2, <4>, 3, 5] == ["2", <"4">, "3", "5"]Same as map but the function is also applied to the index of each element (starting at zero).
indexedMap Tuple.pair [1, <2>, 4] == [(0, 1), <(1, 2)>, (2, 4)]
indexedMap Tuple.pair ["hi", <"wow">] == [(0, "hi"), <(1, "wow")>]Same as map but the function also takes a boolean indicating wether it is current/the selected element.
selectedMap Tuple.pair [<2>, 4] == [<(True, 2)>, (False, 4)]
selectedMap Tuple.pair ["en", "fr", <"ge">] == [(False, "en"), (False, "fr"), <(True, "ge")>]Same as map but the function also takes the index of the element (starting at zero) and a boolean indicating wether it is current/the selected element.
let
myFun =
(\ index isCurrent elem ->
(index, isCurrent, String.fromInt elem)
)
in
selectedMap myFun [1, <2>, 4] == [(0, False, "1"), <(1, True, "2")>, (2, False, "4")]
A
ZipListis a list that has a single selected element. We call it current as "the one that is currently selected".