OSDN Git Service

In Elm.
authorsforman <sforman@hushmail.com>
Fri, 28 Jul 2023 21:18:12 +0000 (14:18 -0700)
committersforman <sforman@hushmail.com>
Fri, 28 Jul 2023 21:18:12 +0000 (14:18 -0700)
implementations/Elm/.gitignore [new file with mode: 0644]
implementations/Elm/elm.json [new file with mode: 0644]
implementations/Elm/src/Main.elm [new file with mode: 0644]
implementations/Python/README.md

diff --git a/implementations/Elm/.gitignore b/implementations/Elm/.gitignore
new file mode 100644 (file)
index 0000000..4bc8535
--- /dev/null
@@ -0,0 +1 @@
+elm-stuff
diff --git a/implementations/Elm/elm.json b/implementations/Elm/elm.json
new file mode 100644 (file)
index 0000000..ce2a08d
--- /dev/null
@@ -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 (file)
index 0000000..72a1f41
--- /dev/null
@@ -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) ]
+    ]
index ee20c5f..50a4949 100644 (file)
@@ -1,3 +1,5 @@
+This is out of date.  The Python implementation was the original one.
+
 Thun
 
 A Dialect of Joy.