Skip to content

Instantly share code, notes, and snippets.

@leojpod
Created May 22, 2017 14:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save leojpod/3e6162261be42ecc4117eee2deab5212 to your computer and use it in GitHub Desktop.
Save leojpod/3e6162261be42ecc4117eee2deab5212 to your computer and use it in GitHub Desktop.
View.elm for the board: HTML version
boardDisplay : Board -> Html BoardMsg
boardDisplay board =
table []
((tr []
((td [] [])
:: ((List.range 0 9)
|> List.map (\col -> td [] [ text (toString col) ])
)
)
)
:: (List.indexedMap rowView board)
)
rowView : Int -> List Cell -> Html BoardMsg
rowView idx row =
tr [] ((td [] [ text (toString idx) ]) :: (List.map cellView row))
cellView : Cell -> Html BoardMsg
cellView cell =
case cell of
Empty ->
td [] [ text "." ]
Dead ->
td [] [ text "-" ]
Alive ->
td [] [ text "X" ]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment