lue-bird/elm-linear-direction/3.0.0

NOTE: the latest version is 11.2.0

LinearDirection

FirstToLast, LastToFirst.

= FirstToLast
| LastToFirst

Either FirstToLast or LastToFirst.

util

The other direction. LastToFirst ⇆ FirstToLast

for indices or amounts

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

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

import LinearDirection exposing (toFirstToLast)


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