Use Array.Extra

This commit is contained in:
Emi Simpson 2023-07-03 20:37:36 -04:00
parent b258ffbeb9
commit 322eae3ee7
Signed by: Emi
GPG Key ID: A12F2C2FFDC3D847
3 changed files with 6 additions and 10 deletions

View File

@ -11,7 +11,8 @@
"elm/html": "1.0.0",
"elm/json": "1.1.3",
"elm/svg": "1.0.1",
"elm/url": "1.0.0"
"elm/url": "1.0.0",
"elm-community/array-extra": "2.6.0"
},
"indirect": {
"elm/time": "1.0.0",

View File

@ -1,15 +1,9 @@
module FunkyFunktions exposing (..)
import Array exposing (get, set)
constant a b = a
flip f a b = f b a
withCmd cmd model = (model, cmd)
withoutCmd model = (model, Cmd.none)
andCmd cmd2 (model, cmd1) = (model, Cmd.batch [cmd1, cmd2])
curry2 f (a, b) = f a b
uncurry2 f a b = f (a, b)
updateArray i f a =
case get i a of
Just e -> set i (f e) a
Nothing -> a
uncurry2 f a b = f (a, b)

View File

@ -4,6 +4,7 @@ import FunkyFunktions exposing (..)
import Stickers exposing (Sticker, StickerContent(..), viewSticker)
import Array exposing (Array, get, set)
import Array.Extra as Array
import Browser
import Browser.Dom exposing (getViewport, Viewport)
import Browser.Navigation exposing (Key)
@ -167,7 +168,7 @@ updateTileText text tile =
modTileInColumn : Int -> (Tile -> Tile) -> Column -> Column
modTileInColumn tileIndex f column =
{ column | tiles =
updateArray
Array.update
tileIndex
f
column.tiles
@ -176,7 +177,7 @@ modTileInColumn tileIndex f column =
modColumnInPage : Int -> (Column -> Column) -> Model -> Model
modColumnInPage columnIndex f model =
{ model | columns =
updateArray
Array.update
columnIndex
f
model.columns