From 590a5b207ce9ddb8a66979ffa66e3ad1038a30fd Mon Sep 17 00:00:00 2001 From: sforman Date: Fri, 28 Jul 2023 14:18:12 -0700 Subject: [PATCH] In Elm. --- implementations/Elm/.gitignore | 1 + implementations/Elm/elm.json | 24 +++++++++++++++++ implementations/Elm/src/Main.elm | 56 ++++++++++++++++++++++++++++++++++++++++ implementations/Python/README.md | 2 ++ 4 files changed, 83 insertions(+) create mode 100644 implementations/Elm/.gitignore create mode 100644 implementations/Elm/elm.json create mode 100644 implementations/Elm/src/Main.elm diff --git a/implementations/Elm/.gitignore b/implementations/Elm/.gitignore new file mode 100644 index 0000000..4bc8535 --- /dev/null +++ b/implementations/Elm/.gitignore @@ -0,0 +1 @@ +elm-stuff diff --git a/implementations/Elm/elm.json b/implementations/Elm/elm.json new file mode 100644 index 0000000..ce2a08d --- /dev/null +++ b/implementations/Elm/elm.json @@ -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": {} + } +} diff --git a/implementations/Elm/src/Main.elm b/implementations/Elm/src/Main.elm new file mode 100644 index 0000000..72a1f41 --- /dev/null +++ b/implementations/Elm/src/Main.elm @@ -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) ] + ] diff --git a/implementations/Python/README.md b/implementations/Python/README.md index ee20c5f..50a4949 100644 --- a/implementations/Python/README.md +++ b/implementations/Python/README.md @@ -1,3 +1,5 @@ +This is out of date. The Python implementation was the original one. + Thun A Dialect of Joy. -- 2.11.0