Erlang firtst steps

How to start with erlang?

First steps

Check it

  1. Run erl.exe on console
  2. Type: 2 + 2.<Enter>
  3. You return 4? good 🙂
  4. CTRL-Z exit from compiler

 Tuplets

  • Point = {4,5}.
    • {X,Y} = Point.
    • X.
    • {X,_} = Point.

List

  • [1, 2, 3, {numbers,[4,5,6]}, 5.34, atom].
  • [1,2,3] ++ [4,5].
  • [1,2,3,4,5] — [1,2,3].
  • [1,2,3] — [1,2] — [3]. (!! both ++ and — are right-associative)
  • List = [2,3,4].
  • NewList = [1|List].

List Comprehensions

  • [N*N*N || N <- [1,2,3,4,5,6,7,8,9,10,11,12,13]].
  • [X || X <- [1,2,3,4,5,6,7,8,9,10], X rem 2 =:= 0].
  • RestaurantMenu = [{steak, 5.99}, {beer, 3.99}, {poutine, 3.50}, {kitten, 20.99}, {water, 0.00}].
    • [{Item, Price*1.07} || {Item, Price} <- RestaurantMenu, Price >= 3, Price =< 10].
  • Weather = [{toronto, rain}, {montreal, storms}, {london, fog}, {paris, sun}, {boston, fog}, {vancouver, snow}].

Links

  1. http://learnyousomeerlang.com/content

Proudly powered by WordPress | Theme: Baskerville 2 by Anders Noren.

Up ↑