Last active
September 21, 2016 09:10
-
-
Save lydell/37634f349a1e1d3808cca43234496653 to your computer and use it in GitHub Desktop.
Crazy elm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Main exposing (..) | |
import Html exposing (Html, div, button, text) | |
import Html.App | |
import Html.Events exposing (onClick) | |
main : Program Never | |
main = | |
Html.App.beginnerProgram | |
{ model = 0 | |
, update = always | |
, view = view | |
} | |
view : Int -> Html Int | |
view count = | |
div [] | |
[ button [ onClick (count - 1) ] [ text "-" ] | |
, text (toString count) | |
, button [ onClick (count + 1) ] [ text "+" ] | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Html exposing (..) | |
import Html.App exposing (..) | |
import Html.Events exposing (..) | |
main = | |
beginnerProgram | |
{ model = 0 | |
, update = always | |
, view = v | |
} | |
v c = | |
[ button [ c - 1 |> onClick ] [ text "-" ] | |
, c |> text << toString | |
, button [ c + 1 |> onClick ] [ text "+" ] | |
] | |
|> (div <| []) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment