Skip to content

Instantly share code, notes, and snippets.

@crazymykl
Created May 14, 2016 20:48
Show Gist options
  • Save crazymykl/8d3c75897c524939d806288adf440f42 to your computer and use it in GitHub Desktop.
Save crazymykl/8d3c75897c524939d806288adf440f42 to your computer and use it in GitHub Desktop.
Repetition.
import Array exposing (Array)
type alias Model = Array (Array Color)
type alias Point = (Int, Int)
type Color = Red | Green | Blue | Purple
set2d : Point -> Color -> Model -> Model
set2d (x, y) color model =
Array.get y model
|> Maybe.map (flip (Array.set y << Array.set x color) model)
|> Maybe.withDefault model
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment