Advertisement
Guest User

Untitled

a guest
Oct 24th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.63 KB | None | 0 0
  1. % Jorge Andres Gonzales A01280927
  2. % Andres Sosa Silva A01176075
  3. -module(ej2).
  4. -export([calcula/2]).
  5.  
  6. calcula(N,M)->
  7.   receive
  8.     {suma,X,Y} ->
  9.       io:format("Suma: ~p~n",[X+Y]),
  10.       calcula(N+X+Y,X+Y);
  11.     {multiplica, X, Y} ->
  12.       io:format("Multiplicacion: ~p~n",[X*Y]),
  13.       calcula(N+X*Y,X*Y);
  14.     {ultimo, P} ->
  15.       io:format("Valor mas reciente ~p mandado a : ~p~n", [M,P]),
  16.       %P ! {resultado,M},
  17.       calcula(N,M);
  18.     {total, P} ->
  19.       io:format("Caulculo total ~p mandado a : ~p~n", [N,P]),
  20.       %P ! {resultado,N},
  21.       calcula(N,M);
  22.     {termina} ->
  23.       io:format("Done ~n", [])
  24.   end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement