ex-scopes/lib/csys/csys.ex

28 lines
637 B
Elixir

defmodule Scopes.CSys do
require Logger
alias Scopes.Core.Actor
def neuron(scope) do
#Logger.info("create neuron, scope: #{inspect scope}")
Logger.info([info: "create neuron", scope: inspect(scope)])
Actor.create(fn msg -> process(msg, scope) end)
end
def synapse(rcvr, op) do
fn msg -> Actor.send(rcvr, op.(msg)) end
end
def process(msg, scope) do
proc(scope).(msg, scope)
end
# helper functions
def proc(scope), do: hd(code(scope))
def state(scope), do: elem(scope, 0)
def code(scope), do: elem(scope, 1)
def syns(scope), do: elem(scope, 2)
def env(scope), do: elem(scope, 3)
end