15
An introduction to Elm by @tcoopman

Elm session socrates

Embed Size (px)

Citation preview

An introduction to Elmby @tcoopman

Some examplesWhy should I care?

What is ElmIntroduction and examplesQuestions, discussions,...

Why shouldyou care?

A really nice languageA nice introduction into functional

programmingNice and helping community

Any reasonwhy not?

It's new (version 0.16)This means there are some quirksBut these are things being worked on

(for example in 0.17)You have to find out things for yourself

So shouldyou care?

YES!OF

COURSE!

Elmcreated by Evan Czaplicki @czaplic

Why are wedoing slides?

SHOWME THECODE!

-- Any live cell with fewer than two live neighbours dies, as if caused by under-population.underPopulationRule:Cell->Neighbours->LifeCycleunderPopulationRulecellneighbours=casecellofAlive->ifnumberOfLiveneighbours<2thenDies

elseSame

Dead->Same

-- Any live cell with two or three live neighbours lives on to the next generation.livesOnRule:Cell->Neighbours->LifeCyclelivesOnRulecellneighbours=casecellofAlive->letnumberOfLiveNeighbours=numberOfLiveneighbours

inif((numberOfLiveNeighbours==2)||(numberOfLiveNeighbours==3))thenSame

elseDies

Dead->Same

typeTreea=Empty|Nodea(Treea)(Treea)

empty:Treeaempty=

Empty

singleton:a->Treeasingletonv=

NodevEmptyEmpty

insert:comparable->Treecomparable->Treecomparableinsertxtree=

casetreeofEmpty->

singletonx

Nodeyleftright->ifx>ythen

Nodeyleft(insertxright)

elseifx<ythenNodey(insertxleft)right

elsetree