view arrows/@loop1/loop1.m @ 27:5de03f77dae1

Added documentation about types and revised arrow type specifications.
author samer
date Sat, 19 Jan 2013 14:22:09 +0000
parents 672052bd81f8
children
line wrap: on
line source
% 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@typelist(N), {S}] -> [B@typelist(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