start csys development with simple neuron implementation

This commit is contained in:
Helmut Merz 2026-04-19 17:40:42 +02:00
parent 9a20b98440
commit 88e67b02ec
4 changed files with 43 additions and 6 deletions

View file

@ -1,16 +1,27 @@
# Xplore
# Scopes
**TODO: Add description**
Yet another implementation of the unfamous `scopes` framework.
## Installation
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `xplore` to your list of dependencies in `mix.exs`:
You can use the development checkout from Git and reference it as a dependency
in `mix.exs` like this:
```elixir
def deps do
[
{:xplore, "~> 0.1.0"}
{:scopes, path: "../ex-scopes"}
]
end
```
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
by adding `scopes` to your list of dependencies in `mix.exs`:
```elixir
def deps do
[
{:scopes, "~> 0.1.0"}
]
end
```

8
lib/csys/csys.ex Normal file
View file

@ -0,0 +1,8 @@
defmodule Scopes.CSys do
#alias Scopes.Core.Actor
def neuron(proc, scope) do
#{state, syns, env} = scope
fn msg -> proc.(msg, scope) end
end
end

View file

@ -7,11 +7,12 @@ defmodule Scopes.CoreTest do
this = self()
ac = Actor.create(fn msg -> send(this, msg) end)
Actor.send(ac, "Hello Actor!")
assert_receive "Hello Actor!"
Actor.become(ac, fn _msg -> send(this, "Goodbye") end)
Actor.send(ac, "Hello Actor!")
Actor.stop(ac)
assert_receive "Hello Actor!"
assert_receive "Goodbye"
refute_received msg, "unhandled message(s): #{inspect msg}"
end
end
end

17
test/csys_test.exs Normal file
View file

@ -0,0 +1,17 @@
defmodule Scopes.CSysTest do
use ExUnit.Case, async: true
alias Scopes.Core.Actor
alias Scopes.CSys
describe "basic:" do
test "minimal-neural-net" do
this = self()
zero = Actor.create(CSys.neuron(
fn msg, _scope -> send(this, msg) end, {nil, [], this}))
Actor.send(zero, "Hello Zero!")
Actor.stop(zero)
assert_receive "Hello Zero!"
refute_received msg, "unhandled message(s): #{inspect msg}"
end
end
end