Add tasks for all the new languages
This commit is contained in:
parent
9dc3c2bb62
commit
bba7bfd280
13208 changed files with 134745 additions and 0 deletions
39
Task/Reverse-a-string/Elm/reverse-a-string.elm
Normal file
39
Task/Reverse-a-string/Elm/reverse-a-string.elm
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
-- The import on the next line provides the reverse string
|
||||
-- functionality satisfying the rosettacode.org task description.
|
||||
import String exposing (reverse)
|
||||
|
||||
-- The rest is fairly boilerplate code demonstrating
|
||||
-- interactively that the reverse function works.
|
||||
import Html exposing (Html, Attribute, text, div, input)
|
||||
import Html.Attributes exposing (placeholder, value, style)
|
||||
import Html.Events exposing (on, targetValue)
|
||||
import Html.App exposing (beginnerProgram)
|
||||
|
||||
main = beginnerProgram { model = "", view = view, update = update }
|
||||
|
||||
update newStr oldStr = newStr
|
||||
|
||||
view : String -> Html String
|
||||
view forward =
|
||||
div []
|
||||
([ input
|
||||
[ placeholder "Enter a string to be reversed."
|
||||
, value forward
|
||||
, on "input" targetValue
|
||||
, myStyle
|
||||
]
|
||||
[]
|
||||
] ++
|
||||
[ let backward = reverse forward
|
||||
in div [ myStyle] [text backward]
|
||||
])
|
||||
|
||||
myStyle : Attribute msg
|
||||
myStyle =
|
||||
style
|
||||
[ ("width", "100%")
|
||||
, ("height", "20px")
|
||||
, ("padding", "5px 0 0 5px")
|
||||
, ("font-size", "1em")
|
||||
, ("text-align", "left")
|
||||
]
|
||||
Loading…
Add table
Add a link
Reference in a new issue