diff arrows/@loop1/loop1.m @ 0:672052bd81f8

Initial partial import.
author samer
date Wed, 19 Dec 2012 22:38:28 +0000
parents
children 5de03f77dae1
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/arrows/@loop1/loop1.m	Wed Dec 19 22:38:28 2012 +0000
@@ -0,0 +1,21 @@
+% loop1 - Looping feedback arrow for stateful arrows.
+%
+% loop1 ::
+%    N:natural  ~'number of inputs for this arrow',
+%    M:natural  ~'number of outputs for this arrow',
+%    ({[N]->size} -> ([A:arglist(N), {S}] -> [B:arglist(M), {S}])) 
+%                           ~'function to map input sizes to state transformer',
+%    ({[N]->size} -> S0:S)  ~'function to map size of input to initial state'
+% -> arrow(A,B,S) ~'arrow from A to B with state of type S'.
+
+function o=loop1(nin,nout,initfn)
+	if nargin<1, 
+		nin=1; nout=1;
+		initfn=@(sz)deal(@(a,b)deal(a,b),[]); 
+	end
+	s.init=initfn; 
+	s.nin=nin;
+	s.nout=nout;
+	o=class(s,'loop1',arrow(nin,nout));
+end
+