Created
April 25, 2019 14:23
-
-
Save glinesbdev/6473953794f455737dfb1bf3f8425275 to your computer and use it in GitHub Desktop.
Elm String of Strings
This file contains hidden or 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 (main) | |
| import Browser | |
| import Html exposing (Html, button, div, text) | |
| import Html.Events exposing (onClick) | |
| type alias Model = | |
| String | |
| type Msg | |
| = None | |
| initialModel : Model | |
| initialModel = | |
| "" | |
| update : Msg -> Model -> Model | |
| update msg model = | |
| case msg of | |
| None -> | |
| model | |
| combineStrings : List String -> String | |
| combineStrings list = | |
| if List.isEmpty list then | |
| "" | |
| else | |
| case list of | |
| x::xs -> | |
| let | |
| formatted = | |
| List.map (\s -> s ++ "'" ++ "'") list | |
| in | |
| "'" ++ (List.foldr (++) "" formatted) ++ "" | |
| |> String.dropRight 1 | |
| _ -> | |
| "" | |
| view : Model -> Html Msg | |
| view model = | |
| div [] [ text <| combineStrings ["head head head head", "main main . sidebar", "footer footer footer footer"] ] | |
| main : Program () Model Msg | |
| main = | |
| Browser.sandbox | |
| { init = initialModel | |
| , view = view | |
| , update = update | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment