lovasoa/elm-rolling-list/1.0.0

NOTE: this package is not compatible with Elm 0.19.1

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 : RollingList a -> Maybe a

Returns the currently selected element in the list

>>> current (fromList [1,2,3])
Just 1
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.