3. Some examples
Why should I care?
What is Elm
Introduction and examples
Questions, discussions,...
4.
5. Why should
you care?
A really nice language
A nice introduction into functional
programming
Nice and helping community
6. Any reason
why not?
It's new (version 0.16)
This means there are some quirks
But these are things being worked on
(for example in 0.17)
You have to find out things for yourself
10. -- Any live cell with fewer than two live neighbours dies, as if caused by under-popu
underPopulationRule : Cell -> Neighbours -> LifeCycle
underPopulationRule cell neighbours =
case cell of
Alive ->
if numberOfLive neighbours < 2 then
Dies
else
Same
Dead ->
Same
-- Any live cell with two or three live neighbours lives on to the next generation.
livesOnRule : Cell -> Neighbours -> LifeCycle
livesOnRule cell neighbours =
case cell of
Alive ->
let
numberOfLiveNeighbours = numberOfLive neighbours
in
if ((numberOfLiveNeighbours == 2) || (numberOfLiveNeighbours == 3)) then
Same
else
Dies
Dead ->
Same
11. type Tree a
= Empty
| Node a (Tree a) (Tree a)
empty : Tree a
empty =
Empty
singleton : a -> Tree a
singleton v =
Node v Empty Empty
insert : comparable -> Tree comparable -> Tree comparable
insert x tree =
case tree of
Empty ->
singleton x
Node y left right ->
if x > y then
Node y left (insert x right)
else if x < y then
Node y (insert x left) right
else
tree