Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Erlang

585 views

Published on

a extended version of a previous lighting's talk, i presented this in a functional society meeting.

Published in: Technology, News & Politics
  • Be the first to comment

  • Be the first to like this

Erlang

  1. 1. @alepoletto
  2. 2. What is/ Why?• Functional programming language.• Large emphasis on concurrency and high reliability• Erlangs runtime system has built-in support for concurrency, distribution and fault tolerance• Use the Actor Model• Used in telecoms, banking, e-commerce, computer telephony and instant messaging.• Runs inside a virtual machine. @alepoletto
  3. 3. Who created? @alepoletto
  4. 4. Reference to A. K. Erlang @alepoletto
  5. 5. Who is using @alepoletto
  6. 6. @alepoletto
  7. 7. Variables and Atoms• X = 2 + 2.• X = 4.• X = 7.• x = 4. (can’t be lower case)• Lower case is reserved to atoms• Lets say that car is a atom.• Them car is a car nothing more.• Useful to express values @alepoletto
  8. 8. Functionssoma(A, B) -> A+B.ola() -> io:format(“Ola”).olaSoma(A) -> ola(), soma(A,1). @alepoletto
  9. 9. Modules-module(society).-export([soma/2]).-compile(export_all).soma(A, B) -> A+B.ola() -> io:format(“Ola”). @alepoletto
  10. 10. Pattern Matcher @alepoletto
  11. 11. Pattern Matchingfunction jovem(Pessoa) if Pessoa == chaves then print(“Jovem ainda”) else if Pessoa == madruga then print(“Velho”) else print(“Não sei")end @alepoletto
  12. 12. Pattern Matchingjovem(chaves) -> io:format(“Jovem ainda”);jovem(madruga) -> io:format(“Velho”);jovem(_) -> io:format(“Não Sei”).adulto(X) when X >= 21 -> true;adulto(_) -> false. @alepoletto
  13. 13. Lets be Functionalfatorial(0) -> 1;fatorial(N) -> when N > 0 -> N * fatorial(N-1).map(_, []) -> [];map(F, [H|T]) -> [F(H)|map(F,T)].L = [1,2,3,4,5].map(fun society:fatorial/1, L).map(fun(X) -> X + 1 end, L). @alepoletto
  14. 14. Actors @alepoletto
  15. 15. Actorscobra() -> receive {From, speak} -> From ! “Youre the disease, and Im the cure."; {From, deal} -> From ! “I dont deal with psychos. I put them away. "; _ -> io:format(“no talk") end. @alepoletto
  16. 16. ActorsStallone = spawn(society, cobra, []).<0.55.0>Stallone! {self(), speak}.flush()."Youre the disease, and Im the cure. “Stallone! {self(), danca}.flush(). @alepoletto
  17. 17. Actorscobra() -> receive {From, speak} -> From ! “Youre the disease, and Im the cure." cobra(); {From, deal} -> From ! “I dont deal with psychos. I put them away. " cobra(); _ -> io:format(“no talk") cobra(); end. @alepoletto
  18. 18. ActorsStallone! {self(), speak}.“Youre the disease, and Im the cure.“ Stallone! {self(), deal}.“I dont deal with psychos. I put them away. “Stallone! {self(), shoot}.“no talk” @alepoletto
  19. 19. Reference• http://learnyousomeerlang.com/• http://www.erlang.org/• http://en.wikipedia.org/wiki/Erlang_(programming_language) @alepoletto
  20. 20. Thank You @alepoletto

×