% hello world program -module(helloworld). create_dlist(0) -> []; create_dlist(N) -> [spwan(?Moduele, dlist, [0])] || _ <- list:seq(1,N). dlist(V) -> receive {get, P} -> P ! V, dlist(V); {set, P} -> dlist(V) end. dlist_to_list([], L) -> L; dlist_to_list([P|Ps], L) -> P ! {get, self()}, receive V -> dlist_to_list(Ps, L ++ [V]) end. dmap([], _) -> ok; dmap(F, Fun) -> P ! {get, self()}, receive V -> P ! {set, Fun(V)} end dmap([P|Ps], Fun) -> P ! {get, self()}, receive V -> P ! {set, Fun(V)] end dmap(Ps, Fun).
We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy. Accept Learn more