samer@0: % loop1 - Looping feedback arrow for stateful arrows. samer@0: % samer@0: % loop1 :: samer@0: % N:natural ~'number of inputs for this arrow', samer@0: % M:natural ~'number of outputs for this arrow', samer@27: % ({[N]->size} -> ([A@typelist(N), {S}] -> [B@typelist(M), {S}])) samer@0: % ~'function to map input sizes to state transformer', samer@0: % ({[N]->size} -> S0:S) ~'function to map size of input to initial state' samer@0: % -> arrow(A,B,S) ~'arrow from A to B with state of type S'. samer@0: samer@0: function o=loop1(nin,nout,initfn) samer@0: if nargin<1, samer@0: nin=1; nout=1; samer@0: initfn=@(sz)deal(@(a,b)deal(a,b),[]); samer@0: end samer@0: s.init=initfn; samer@0: s.nin=nin; samer@0: s.nout=nout; samer@0: o=class(s,'loop1',arrow(nin,nout)); samer@0: end samer@0: