diff options
-rw-r--r-- | elm/.gitignore | 2 | ||||
-rw-r--r-- | elm/day1.elm | 26 |
2 files changed, 28 insertions, 0 deletions
diff --git a/elm/.gitignore b/elm/.gitignore new file mode 100644 index 0000000..ab307b2 --- /dev/null +++ b/elm/.gitignore @@ -0,0 +1,2 @@ +build +cache diff --git a/elm/day1.elm b/elm/day1.elm new file mode 100644 index 0000000..dd63919 --- /dev/null +++ b/elm/day1.elm @@ -0,0 +1,26 @@ +product = foldl (*) 1 + +xFields = map .x + +multiply x y = case y of + 0 -> 0 + y -> y + multiply x (y-1) + +type Person = { name : String, age : Int, + address : { calle : String, pais : String } } + +yo : Person +yo = { name = "Guillermo", age = 23, + address = { calle = "Arroyo Fontarrón", pais = "España" } } + +tu : Person +tu = { name = "Paco", age = 15, + address = { calle = "Por allí", pais = "Congo" } } + +persons = [yo, tu] + +olderThan16 = filter ((>) 16 . .age) + +olderThan16_safe = filter (\p -> case p.age of + Nothing -> False + Just age -> age > 16)
\ No newline at end of file |