コード風プロンプト例8f Erlangのactor:複数アクター間のメッセージルーティング
Simulates Erlang-style actor message routing with multiple concurrent processes. Use this to test how the model handles asynchronous message passing and actor coordination patterns.
/plugin marketplace add kokuyouwind/claude-plugins/plugin install code-like-prompt@kokuyouwind-pluginsEmulate the following Erlang-style code internally (without using external tools or interpreter). Output only what io:format() commands would output. Do not show any explanations, code, variables, or other messages.
-module(multi_actor).
-export([main/0]).
main() ->
Self = self(),
% Coordinator actor
Coordinator = spawn(fun() ->
receive
{result, Worker1Result} ->
receive
{result, Worker2Result} ->
io:format("~s~n", [Worker1Result ++ Worker2Result]),
Self ! done
end
end
end),
% Worker actors
spawn(fun() ->
Coordinator ! {result, "foo"}
end),
spawn(fun() ->
Coordinator ! {result, "bar"}
end),
receive
done -> ok
end,
io:format("baz~n").