In Elm.
This commit is contained in:
parent
23504f6ede
commit
590a5b207c
|
|
@ -0,0 +1 @@
|
|||
elm-stuff
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"type": "application",
|
||||
"source-directories": [
|
||||
"src"
|
||||
],
|
||||
"elm-version": "0.19.1",
|
||||
"dependencies": {
|
||||
"direct": {
|
||||
"elm/browser": "1.0.2",
|
||||
"elm/core": "1.0.5",
|
||||
"elm/html": "1.0.0"
|
||||
},
|
||||
"indirect": {
|
||||
"elm/json": "1.1.3",
|
||||
"elm/time": "1.0.0",
|
||||
"elm/url": "1.0.0",
|
||||
"elm/virtual-dom": "1.0.3"
|
||||
}
|
||||
},
|
||||
"test-dependencies": {
|
||||
"direct": {},
|
||||
"indirect": {}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
module Main exposing (..)
|
||||
|
||||
|
||||
import Browser
|
||||
import Html exposing (Html, Attribute, div, input, text)
|
||||
import Html.Attributes exposing (..)
|
||||
import Html.Events exposing (onInput)
|
||||
|
||||
|
||||
|
||||
-- MAIN
|
||||
|
||||
|
||||
main =
|
||||
Browser.sandbox { init = init, update = update, view = view }
|
||||
|
||||
|
||||
|
||||
-- MODEL
|
||||
|
||||
|
||||
type alias Model =
|
||||
{ content : String
|
||||
}
|
||||
|
||||
|
||||
init : Model
|
||||
init =
|
||||
{ content = "" }
|
||||
|
||||
|
||||
|
||||
-- UPDATE
|
||||
|
||||
|
||||
type Msg
|
||||
= Change String
|
||||
|
||||
|
||||
update : Msg -> Model -> Model
|
||||
update msg model =
|
||||
case msg of
|
||||
Change newContent ->
|
||||
{ model | content = newContent }
|
||||
|
||||
|
||||
|
||||
-- VIEW
|
||||
|
||||
|
||||
view : Model -> Html Msg
|
||||
view model =
|
||||
div []
|
||||
[ input [ placeholder "Text to reverse", value model.content, onInput Change ] []
|
||||
, div [] [ text (String.reverse model.content) ]
|
||||
]
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
This is out of date. The Python implementation was the original one.
|
||||
|
||||
Thun
|
||||
|
||||
A Dialect of Joy.
|
||||
|
|
|
|||
Loading…
Reference in New Issue