mirror of
https://github.com/mdgriffith/elm-optimize-level-2.git
synced 2024-11-29 12:46:32 +03:00
44 lines
493 B
Elm
44 lines
493 B
Elm
module Main exposing (main)
|
|
|
|
{-| -}
|
|
|
|
import Html
|
|
|
|
|
|
type MyType
|
|
= Zero
|
|
| One Int
|
|
| Two String String
|
|
|
|
|
|
values =
|
|
[ Zero
|
|
, One 5
|
|
, Two "Two" "two"
|
|
]
|
|
|
|
|
|
many =
|
|
List.repeat 1000 values
|
|
|> List.concat
|
|
|
|
|
|
addMyType mine sum =
|
|
case mine of
|
|
Zero ->
|
|
sum
|
|
|
|
One i ->
|
|
i + sum
|
|
|
|
Two _ _ ->
|
|
sum
|
|
|
|
|
|
main =
|
|
let
|
|
sum =
|
|
List.foldl addMyType 0 many
|
|
in
|
|
Html.text (String.fromInt sum)
|