Erlang
@aupajo
github.com/aupajo
Thursday, 27 June 13
Thursday, 27 June 13
Thursday, 27 June 13
Thursday, 27 June 13
Thursday, 27 June 13
✔ PUNS
Thursday, 27 June 13
WHY?
Thursday, 27 June 13
CONCURRENCY
Thursday, 27 June 13
SCALING
Thursday, 27 June 13
ROBUSTNESS
AXD301 – 99.9999999%
Thursday, 27 June 13
FUN!
Thursday, 27 June 13
WHAT’S IT USED
FOR?
Thursday, 27 June 13
Ericsson/T-Mobile/Motorola mobile networks
Amazon’s SimpleDB
Facebook’s Chat
Delicious
Heroku’s Routing Mesh
Riak (distrib...
A BRIEF INTRO…
Thursday, 27 June 13
17.
FirstName.
"hello".
[104,101,108,108,111].
anAtom.
{joe, 1.95}.
integer
variable
string
list
atom
tuple
Thursday, 27 J...
QUIZ!
X = 19.
Y = 11.
X = X + Y.
?
WHAT DOES THIS CODE DO?
(Hint: the “.” is equivalent to “;” in other languages.)
Thursd...
QUIZ!
X = 19.
Y = 11.
X = X + Y.
** exception error: no match of
right hand side value 30
WHAT DOES THIS CODE DO?
Thursday...
VARIABLES
CAN’T VARY
Thursday, 27 June 13
= ISN’T =
Thursday, 27 June 13
PATTERN-
MATCHING
Thursday, 27 June 13
X = 5+7.
Thursday, 27 June 13
X = 5+7.
Thursday, 27 June 13
X = 12.
Thursday, 27 June 13
X = 12.
“Hmm… X is unbound…”
Thursday, 27 June 13
X = 12.
“What can I do to make this
statement true?”
Thursday, 27 June 13
X
Thursday, 27 June 13
12
Thursday, 27 June 13
12 = 5+7.
Thursday, 27 June 13
12 = 5+7.
Thursday, 27 June 13
12 = 12.
Thursday, 27 June 13
12 = 12.
“Yes! It matches!”
Thursday, 27 June 13
TUPLES
THE BUSINESS
Thursday, 27 June 13
Point = {12, 45}.
{X,Y} = {12, 45}.
Thursday, 27 June 13
Person = {person,
{name, joe},
{height, 1.82},
{eyecolour, brown}}.
Thursday, 27 June 13
{person,
{name, Who},
{height, _},
{eyecolour, _}} = Person.
Thursday, 27 June 13
{person, {name, Who}, _, _} = Person.
Thursday, 27 June 13
{_, {_, Who}, _, _} = Person.
Thursday, 27 June 13
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
X ok X is ok
{X,Y,abc} {12,ok,abc}
X is 12,
Y is ok
{X,Y} {33,44,"w...
CLAUSES
Thursday, 27 June 13
area(rectangle, W, H) -> W * H.
area(rectangle, 10, 20). 200
Thursday, 27 June 13
area(rectangle, W, H) -> W * H;
area(circle, R) -> R * 3.14.
Thursday, 27 June 13
area(rectangle, 10, 30).
area(rectangle, W, H) -> W * H.
area(circle, R) -> R * 3.14.
“I recognize that!”
Thursday, 27 Jun...
LISTS
Thursday, 27 June 13
[Head|Tail] = [a,b,c,d].
Head.
Tail.
a
[b,c,d]
Thursday, 27 June 13
[H|T] = "odd".
H.
T.
"o"
["d","d"]
Thursday, 27 June 13
N = 12.
List = [43, 10, 11, 8, 50].
Smaller = [X || X <- List, X < N].
Bigger = [X || X <- List, X > N].
Thursday, 27 June...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
QUIZ!
HOW DO THESE PATTERNS MATCH?
PATTERN TERM RESULT
[H|T] [a, b, c, d]
H is a
T is [b,c,d]
[{name,Who}|T]
[{name,joe},
...
SOLVING
PROBLEMS
Thursday, 27 June 13
cost(oranges) -> 5;
cost(apples) -> 2;
cost(pears) -> 9;
cost(milk) -> 7.
cost(milk). 7
Thursday, 27 June 13
ShoppingList = [
{oranges, 3},
{apples, 5},
{pears, 2},
{milk, 1}
].
total(ShoppingList).
Thursday, 27 June 13
[{oranges, 3},{apples, 5},…]
total([{Item, N}|T]) ->
cost(Item) * N + total(T);
total([]) -> [].
Thursday, 27 June 13
cheaperThan(Item, List) ->
[X || X <- List, cost(X) < cost(Item)].
Thursday, 27 June 13
qsort([]) -> [];
qsort([Pivot|T) ->
qsort([ X || X <- T, X < Pivot ])
++ [Pivot] ++
qsort([ X || X <- T, X >= Pivot ]).
Th...
PROCESSES
PROCESSES
PROCESSES
PROCESSES
PROCESSES
PROCESSES
PROCESSES
PROCESSES
PROCESSES
Thursday, 27 June 13
THE REAL WORLD
IS PARALLEL
Thursday, 27 June 13
PEOPLE ARE
INDEPENDENT
ENTITIES…
Thursday, 27 June 13
WHO
COMMUNICATE BY
SENDING
MESSAGES
Thursday, 27 June 13
Thursday, 27 June 13
Thursday, 27 June 13
Thursday, 27 June 13
Thursday, 27 June 13
Thursday, 27 June 13
INTERESTING
PROJECTS
Thursday, 27 June 13
Thursday, 27 June 13
Thursday, 27 June 13
Thursday, 27 June 13
Upcoming SlideShare
Loading in …5
×

Introduction to Erlang

629 views
537 views

Published on

An introduction to Erlang, with an angle for Rubyists.

Talk given at Christchurch Ruby in New Zealand on 20 June, 2013.

Title page: Lavanderia (Sturdy)
Body: Avenir (Black)
Code: Monaco (Regular)

Feel free to use the slides for anything you need. Please contact me if you would like the original Keynote files.

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
629
On SlideShare
0
From Embeds
0
Number of Embeds
111
Actions
Shares
0
Downloads
0
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Introduction to Erlang

  1. 1. Erlang @aupajo github.com/aupajo Thursday, 27 June 13
  2. 2. Thursday, 27 June 13
  3. 3. Thursday, 27 June 13
  4. 4. Thursday, 27 June 13
  5. 5. Thursday, 27 June 13
  6. 6. ✔ PUNS Thursday, 27 June 13
  7. 7. WHY? Thursday, 27 June 13
  8. 8. CONCURRENCY Thursday, 27 June 13
  9. 9. SCALING Thursday, 27 June 13
  10. 10. ROBUSTNESS AXD301 – 99.9999999% Thursday, 27 June 13
  11. 11. FUN! Thursday, 27 June 13
  12. 12. WHAT’S IT USED FOR? Thursday, 27 June 13
  13. 13. Ericsson/T-Mobile/Motorola mobile networks Amazon’s SimpleDB Facebook’s Chat Delicious Heroku’s Routing Mesh Riak (distributed database) RabbitMQ (AMPQ messaging server) CouchDB (document-oriented database) MochiWeb (HTTP server) Ejabberd (XMPP IM server) Thursday, 27 June 13
  14. 14. A BRIEF INTRO… Thursday, 27 June 13
  15. 15. 17. FirstName. "hello". [104,101,108,108,111]. anAtom. {joe, 1.95}. integer variable string list atom tuple Thursday, 27 June 13
  16. 16. QUIZ! X = 19. Y = 11. X = X + Y. ? WHAT DOES THIS CODE DO? (Hint: the “.” is equivalent to “;” in other languages.) Thursday, 27 June 13
  17. 17. QUIZ! X = 19. Y = 11. X = X + Y. ** exception error: no match of right hand side value 30 WHAT DOES THIS CODE DO? Thursday, 27 June 13
  18. 18. VARIABLES CAN’T VARY Thursday, 27 June 13
  19. 19. = ISN’T = Thursday, 27 June 13
  20. 20. PATTERN- MATCHING Thursday, 27 June 13
  21. 21. X = 5+7. Thursday, 27 June 13
  22. 22. X = 5+7. Thursday, 27 June 13
  23. 23. X = 12. Thursday, 27 June 13
  24. 24. X = 12. “Hmm… X is unbound…” Thursday, 27 June 13
  25. 25. X = 12. “What can I do to make this statement true?” Thursday, 27 June 13
  26. 26. X Thursday, 27 June 13
  27. 27. 12 Thursday, 27 June 13
  28. 28. 12 = 5+7. Thursday, 27 June 13
  29. 29. 12 = 5+7. Thursday, 27 June 13
  30. 30. 12 = 12. Thursday, 27 June 13
  31. 31. 12 = 12. “Yes! It matches!” Thursday, 27 June 13
  32. 32. TUPLES THE BUSINESS Thursday, 27 June 13
  33. 33. Point = {12, 45}. {X,Y} = {12, 45}. Thursday, 27 June 13
  34. 34. Person = {person, {name, joe}, {height, 1.82}, {eyecolour, brown}}. Thursday, 27 June 13
  35. 35. {person, {name, Who}, {height, _}, {eyecolour, _}} = Person. Thursday, 27 June 13
  36. 36. {person, {name, Who}, _, _} = Person. Thursday, 27 June 13
  37. 37. {_, {_, Who}, _, _} = Person. Thursday, 27 June 13
  38. 38. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  39. 39. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  40. 40. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  41. 41. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  42. 42. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  43. 43. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  44. 44. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  45. 45. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  46. 46. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  47. 47. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  48. 48. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  49. 49. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  50. 50. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  51. 51. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  52. 52. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  53. 53. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT X ok X is ok {X,Y,abc} {12,ok,abc} X is 12, Y is ok {X,Y} {33,44,"word"} FAILS {X,Y,X} {{abc,12},42,{abc, 12}} X is {abc,12}, Y is 42 {X,Y,X} {nifty,42,true} FAILS Thursday, 27 June 13
  54. 54. CLAUSES Thursday, 27 June 13
  55. 55. area(rectangle, W, H) -> W * H. area(rectangle, 10, 20). 200 Thursday, 27 June 13
  56. 56. area(rectangle, W, H) -> W * H; area(circle, R) -> R * 3.14. Thursday, 27 June 13
  57. 57. area(rectangle, 10, 30). area(rectangle, W, H) -> W * H. area(circle, R) -> R * 3.14. “I recognize that!” Thursday, 27 June 13
  58. 58. LISTS Thursday, 27 June 13
  59. 59. [Head|Tail] = [a,b,c,d]. Head. Tail. a [b,c,d] Thursday, 27 June 13
  60. 60. [H|T] = "odd". H. T. "o" ["d","d"] Thursday, 27 June 13
  61. 61. N = 12. List = [43, 10, 11, 8, 50]. Smaller = [X || X <- List, X < N]. Bigger = [X || X <- List, X > N]. Thursday, 27 June 13
  62. 62. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  63. 63. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  64. 64. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  65. 65. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  66. 66. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  67. 67. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  68. 68. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  69. 69. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  70. 70. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  71. 71. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  72. 72. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  73. 73. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  74. 74. QUIZ! HOW DO THESE PATTERNS MATCH? PATTERN TERM RESULT [H|T] [a, b, c, d] H is a T is [b,c,d] [{name,Who}|T] [{name,joe}, {name,mike}] Name is joe, Y is {name,mike} [H|T] [a] H is a T is [] [H|T] [] FAILS Thursday, 27 June 13
  75. 75. SOLVING PROBLEMS Thursday, 27 June 13
  76. 76. cost(oranges) -> 5; cost(apples) -> 2; cost(pears) -> 9; cost(milk) -> 7. cost(milk). 7 Thursday, 27 June 13
  77. 77. ShoppingList = [ {oranges, 3}, {apples, 5}, {pears, 2}, {milk, 1} ]. total(ShoppingList). Thursday, 27 June 13
  78. 78. [{oranges, 3},{apples, 5},…] total([{Item, N}|T]) -> cost(Item) * N + total(T); total([]) -> []. Thursday, 27 June 13
  79. 79. cheaperThan(Item, List) -> [X || X <- List, cost(X) < cost(Item)]. Thursday, 27 June 13
  80. 80. qsort([]) -> []; qsort([Pivot|T) -> qsort([ X || X <- T, X < Pivot ]) ++ [Pivot] ++ qsort([ X || X <- T, X >= Pivot ]). Thursday, 27 June 13
  81. 81. PROCESSES PROCESSES PROCESSES PROCESSES PROCESSES PROCESSES PROCESSES PROCESSES PROCESSES Thursday, 27 June 13
  82. 82. THE REAL WORLD IS PARALLEL Thursday, 27 June 13
  83. 83. PEOPLE ARE INDEPENDENT ENTITIES… Thursday, 27 June 13
  84. 84. WHO COMMUNICATE BY SENDING MESSAGES Thursday, 27 June 13
  85. 85. Thursday, 27 June 13
  86. 86. Thursday, 27 June 13
  87. 87. Thursday, 27 June 13
  88. 88. Thursday, 27 June 13
  89. 89. Thursday, 27 June 13
  90. 90. INTERESTING PROJECTS Thursday, 27 June 13
  91. 91. Thursday, 27 June 13
  92. 92. Thursday, 27 June 13
  93. 93. Thursday, 27 June 13

×