Compare commits

..

No commits in common. "7a73d327527ea9739f563802873b92a83eac6146" and "8b590695bb41107a00e7a41c250aba86880b331a" have entirely different histories.

4 changed files with 12 additions and 13 deletions

View file

@ -1,13 +1,11 @@
defmodule Scopes.CSys do
require Logger
require Scopes.Util
alias Scopes.Core.Actor
alias Scopes.Shape
alias Scopes.Util
def neuron(scope) do
#Logger.info(Util.show [scope])
#Logger.info([scope: inspect(scope)])
Actor.create(fn msg -> process(msg, scope) end)
end
@ -60,7 +58,7 @@ defmodule Scopes.CSys do
# send shortcuts
def send_message(rcvr, head, data \\ %{}) do
Logger.debug(Util.show [rcvr, head, data])
Logger.info rcvr: inspect(rcvr), head: inspect(head), data: inspect(data)
Actor.send(rcvr, Shape.create(head, data: data))
end

View file

@ -1,11 +1,9 @@
defmodule Scopes.CSys.Program do
require Logger
require Scopes.Util
alias Scopes.CSys
alias Scopes.CSys.Environ
alias Scopes.Shape
alias Scopes.Util
defmodule State do
defstruct [:value, :count, :stage, :prog]
@ -76,7 +74,7 @@ defmodule Scopes.CSys.Program do
limit = args[:limit]
data = Shape.data(msg)
state = CSys.state(scope)
Logger.debug(Util.show [data, state.value, threshold, self()])
Logger.info data: data, state_value: state.value, threshold: threshold, self: self()
value_n = state.value + data.value
if value_n >= threshold do
value_out = limit && rem(value_n - 1, limit) + limit || value_n

View file

@ -1,8 +1,9 @@
defmodule Scopes.Util do
defmacro show(fields) do
names = for f <- fields do Macro.to_string(f) end
quote bind_quoted: [names: names, fields: fields] do
Enum.zip(names, fields) |> Map.new
defmacro fields_info(fields) do
names = for {f, _, _} <- fields do f end
quote do
Enum.zip(unquote(names), unquote(fields))
end
end
end

View file

@ -6,8 +6,10 @@ defmodule Scopes.UtilTest do
describe "info:" do
test "fields" do
{a, b, c} = {17, 22, 42}
assert %{"a" => 17, "b" => 22, "c" => 42} = Util.show([a, b, c])
a = 17
b = 22
c = 42
assert [a: 17, b: 22, c: 42] = Util.fields_info([a, b, c])
end
end
end