view arrows/@loop1/loop1.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 5de03f77dae1
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