przemko

Współbieżność -- ciąg Fibonacciego

Jun 14th, 2017
11,044
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.30 KB | None | 0 0
  1. %% fib2.erl
  2.  
  3. -module(fib2).
  4. -export([fib/1]).
  5.  
  6. fib(0) -> 0;
  7. fib(1) -> 1;
  8. fib(N) ->
  9.     fib2(N - 1) + fib(N - 2).
  10.  
  11. fib2(N) ->
  12.     Pid = spawn(fun worker/0),
  13.     Pid ! {self(), N},
  14.     receive
  15.         F -> F
  16.     end.
  17.  
  18. worker() ->
  19.     receive
  20.         {From, N} -> From ! fib(N)
  21.     end.
Advertisement
Comments
  • User was banned
  • Suikzau
    204 days
    # text 0.21 KB | 0 0
    1. Best t33n active cpx link daily updates!
    2.  
    3. Copy and paste the link in a new browser tab and then hit enter!
    4.  
    5. https://crazyporn.@xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
    6.  
    7. Remove the @
  • Zyubi
    200 days
    # text 0.19 KB | 0 0
    1. Best t33n active cpx link daily updates!
    2.  
    3. Copy and paste the link in a new browser tab and then hit enter!
    4.  
    5. https://crazyporn.xxx/members/157354/?asgtbndr=1&play=true&spon=adworld&zone=400
  • User was banned
Add Comment
Please, Sign In to add comment