% adynfir - Apply dynamic FIR filter to input signal
%
% adynfir :: 
%    N:natural ~'number of FIR filter coefficients',
%    M:natural ~'number of samples per input block'
% -> arrow({[[N]], [[M]]}, {[[M]]}, pair(empty,[[N-M]])).

function o=adynfir(N,M)

	o=arr(@(f,u){f,u})*loop(@next,@(sz)zeros(N-1,1));

	function [y,s2]=next(x,s)
		if iscell(x)
			u=[s;x{2}];
			y=conv2(u,x{1},'valid');
			s2=u(M+1:end);
		else
			y=zeros(M,1);
			s2=s;
		end
	end
end
