Advertisement
caparol6991

Untitled

Nov 18th, 2019
1,466
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Erlang 0.34 KB | None | 0 0
  1. allocate({[], Allocated}, _Pid) ->
  2.     erlang:display(Allocated),
  3.     {{[], Allocated}, {error, no_frequency}};
  4. allocate({[Freq|Free], Allocated}, Pid) ->
  5.     erlang:display(Allocated),
  6.     {{Free, [{Freq, Pid}|Allocated]}, {ok, Freq}}.
  7. deallocate({Free, Allocated}, Freq) ->
  8.     NewAllocated=lists:keydelete(Freq, 1, Allocated),
  9.     {[Freq|Free], NewAllocated}.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement