Browse Source

Changed the type of the route operation.

route now takes a simple list of sources, in order of their output. This
change limits the number of expressable route operations. Now, every input of
an operation will be connected to exactly 0 or 1 output. This greatly
simplifies the structure of an operation.
Paul Downen 13 years ago
parent
commit
0007403275
2 changed files with 10 additions and 16 deletions
  1. 5 5
      include/ebb_prim.hrl
  2. 5 11
      src/ebb_prim.erl

+ 5 - 5
include/ebb_prim.hrl

@@ -40,11 +40,11 @@
 %%         B = flatten([B_1, B_2, ..., B_I])
 -record(par, {in, out, ops}).
 
-%% route_N,M,R(A, [ sources(R, Target) || Target <- [1..M] ]) ::=
-%%   { in = N, out = M, map = R }
-%%   where N : number, M : number
-%%         R : [{source, target}]
-%%         source : [1..N], target : [1..M]
+%% route_N,R(A, [ A_I || I <- R ]) ::=
+%%   { in = N, out = length(R), map = R }
+%%   where N : number
+%%         R : [source]
+%%         source : [1..N]
 -record(route, {in, out, map}).
 
 %% sync_N(A_1 * ... * A_N, A_1 * ... A_N) ::= { size = N : number }

+ 5 - 11
src/ebb_prim.erl

@@ -5,7 +5,7 @@
 -export([func/1, func/2,
 	 value/1, values/1,
 	 pipe/1, par/1,
-	 route/3, sync/1,
+	 route/2, sync/1,
 	 split/1, merge/1,
 	 switch/1]).
 
@@ -46,17 +46,11 @@ par(Ops = [_|_]) ->
     {In, Out} = flatten_arity(Ops),
     #par{in=In, out=Out, ops=Ops}.
 
-route(N, M, Map) ->
-    Good = lists:all(fun({Source, Target}) when Source >= 1, Source =< N,
-						Target >= 1, Target =< M ->
-			     true;
-			({_Source, _Target}) ->
-			     false
-		     end,
-		     Map),
+route(N, Map) ->
+    Good = lists:all(fun(Source) -> Source > 0 andalso Source =< N end, Map),
     case Good of
-	true  -> #route{in=N, out=M, map=Map};
-	false -> erlang:error(badarg, [N, M, Map])
+	true  -> #route{in=N, out=length(Map), map=Map};
+	false -> erlang:error(badarg, [N, Map])
     end.
 
 sync(N) when is_number(N) -> #sync{size=N}.