start csys development with simple neuron implementation
This commit is contained in:
parent
9a20b98440
commit
88e67b02ec
4 changed files with 43 additions and 6 deletions
21
README.md
21
README.md
|
|
@ -1,16 +1,27 @@
|
||||||
# Xplore
|
# Scopes
|
||||||
|
|
||||||
**TODO: Add description**
|
Yet another implementation of the unfamous `scopes` framework.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
If [available in Hex](https://hex.pm/docs/publish), the package can be installed
|
You can use the development checkout from Git and reference it as a dependency
|
||||||
by adding `xplore` to your list of dependencies in `mix.exs`:
|
in `mix.exs` like this:
|
||||||
|
|
||||||
```elixir
|
```elixir
|
||||||
def deps do
|
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
|
end
|
||||||
```
|
```
|
||||||
|
|
|
||||||
8
lib/csys/csys.ex
Normal file
8
lib/csys/csys.ex
Normal 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
|
||||||
|
|
@ -7,11 +7,12 @@ defmodule Scopes.CoreTest do
|
||||||
this = self()
|
this = self()
|
||||||
ac = Actor.create(fn msg -> send(this, msg) end)
|
ac = Actor.create(fn msg -> send(this, msg) end)
|
||||||
Actor.send(ac, "Hello Actor!")
|
Actor.send(ac, "Hello Actor!")
|
||||||
|
assert_receive "Hello Actor!"
|
||||||
Actor.become(ac, fn _msg -> send(this, "Goodbye") end)
|
Actor.become(ac, fn _msg -> send(this, "Goodbye") end)
|
||||||
Actor.send(ac, "Hello Actor!")
|
Actor.send(ac, "Hello Actor!")
|
||||||
Actor.stop(ac)
|
Actor.stop(ac)
|
||||||
assert_receive "Hello Actor!"
|
|
||||||
assert_receive "Goodbye"
|
assert_receive "Goodbye"
|
||||||
|
refute_received msg, "unhandled message(s): #{inspect msg}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
17
test/csys_test.exs
Normal file
17
test/csys_test.exs
Normal 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
|
||||||
Loading…
Add table
Reference in a new issue