lue-bird / elm-linear-direction / Dict.Linear

Dict operations that can be applied in either Direction

transform

foldFrom : accumulationValue -> Linear.Direction -> ({ key : key, value : value } -> accumulationValue -> accumulationValue) -> Dict key value -> accumulationValue

Reduce { key, value }-entries in a given Direction from a given initial accumulated thing

import Linear exposing (Direction(..))
import Dict

Dict.fromList
    [ ( "Dies", 39 ), ( "Wonu", 22 ), ( "Eorfe", 18 ) ]
    |> Dict.Linear.foldFrom [] Up (\user -> (::) user.key)
--> [ "Wonu", "Eorfe", "Dies" ]

Dict.fromList
    [ ( "Dies", 39 ), ( "Wonu", 22 ), ( "Eorfe", 18 ) ]
    |> Dict.Linear.foldFrom [] Down (\user -> (::) user.key)
--> [ "Dies", "Eorfe", "Wonu" ]