view arrows/delay.m @ 6:0ce3c2070089

Removed duplicate code and fixed doc in timed_action.
author samer
date Mon, 14 Jan 2013 14:33:37 +0000
parents 672052bd81f8
children
line wrap: on
line source
% delay - arrow implementing a delay line
%
% delay ::
%    W:natural   ~'width of buffer',
%    A           ~'a value to pad delay line with'
% -> arrow({[[N,1]->A]}, {[[N,1]->A]}, {[W]->[[N]->A]}).

function a=delay(n,pad)
	a=loop(@delayfn,@(sz)repmat({repmat(pad,sz)},1,n));
	function [out,buf]=delayfn(in,buf)
		out=buf{1};
		buf=[buf(2:end),{in}];
	end
end