Portal Game v0.1.0 Portal View Source
The Portal Game demonstrates some
of elixir
's best features.
- pattern-matching
- fault-tolerance using supervision trees
- distributed processes
Link to this section Summary
Functions
Pushes data to the left in the given portal
.
Pushes data to the right in the given portal
.
Shoots a new door with the given color.
Starts transferring data
from left
to right
.
Link to this section Functions
Link to this function
push_left(portal) View Source
Pushes data to the left in the given portal
.
Example
iex> Portal.shoot(:blaze_red) # the left door
iex> Portal.shoot(:light_blue) # the right door
iex> portal2 = Portal.transfer(:blaze_red, :light_blue, [1,2,3])
iex> Portal.push_right(portal2)
iex> Portal.push_left(portal2)
#Portal< :blaze_red <=> :light_blue [1, 2, 3] <=> []>
Link to this function
push_right(portal) View Source
Pushes data to the right in the given portal
.
Example
iex> Portal.shoot(:tan) # the left door
iex> Portal.shoot(:brown) # the right door
iex> portal = Portal.transfer(:tan, :brown, [1,2,3])
iex> Portal.push_right(portal)
#Portal< :tan <=> :brown [1, 2] <=> [3]>
Link to this function
shoot(color) View Source
Shoots a new door with the given color.
Example
iex> {:ok, pid} = Portal.shoot(:crimson)
iex> is_pid(pid)
true
Link to this function
transfer(left, right, data) View Source
Starts transferring data
from left
to right
.
Example
iex> Portal.shoot(:lime) # the left door
iex> Portal.shoot(:peach) # the right door
iex> Portal.transfer(:lime, :peach, [1,2,3])
#Portal< :lime <=> :peach [1, 2, 3] <=> []>