Skip to content

Instantly share code, notes, and snippets.

@glinesbdev
Created April 25, 2019 14:23
Show Gist options
  • Select an option

  • Save glinesbdev/6473953794f455737dfb1bf3f8425275 to your computer and use it in GitHub Desktop.

Select an option

Save glinesbdev/6473953794f455737dfb1bf3f8425275 to your computer and use it in GitHub Desktop.
Elm String of Strings
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