lue-bird/elm-linear-direction/1.0.0

NOTE: the latest version is 11.2.0

LinearDirection

FirstToLast, LastToFirst.

= FirstToLast
| LastToFirst

Either FirstToLast or LastToFirst. You might also want to create aliases (e.g. forward and backward)

The other direction. LastToFirst ⇆ FirstToLast

for indices or amounts

toFirstToLast : Int -> LinearDirection -> { length : Int } -> Int

Translate an amount or index to one that is used FirstToLast.

at index direction =
    Array.get
        (LinearDirection.toFirstToLast index
            direction
            { length = Array.length array }
        )