lovasoa / elm-rolling-list / RollingList

Module description

Functions

fromList : List a -> RollingList a

Create a rolling list from a normal list

toList (fromList [1,2,3])
--> [1,2,3]

roll : RollingList a -> RollingList a

Return a New RollingList, with the current element set to the next element

toList (roll (fromList [1,2,3]))
--> [2,3,1]

current (roll (fromList [1,2,3]))
--> Just 2

current (fromList [1, 2] |> roll |> roll)
--> Just 1

current (fromList [1] |> roll |> roll |> roll)
--> Just 1

rollBack : RollingList a -> RollingList a

Return a New RollingList, with the current element set to the previous element

toList (rollBack (fromList [1,2,3]))
--> [3,1,2]

current (rollBack (fromList [1,2,3]))
--> Just 3

current : RollingList a -> Maybe a

Returns the currently selected element in the list

current (fromList [1,2,3])
--> Just 1

current (fromList [])
--> Nothing

toList : RollingList a -> List a

Create a normal list from a rolling list

toList (fromList [1,2])
--> [1,2]

Definition


type alias RollingList a =
{ previous : List a
, next : List a 
}

The rolling list type.