view arrows/delay.m @ 2:7357e1dc2ad6

Simplified scheduler library with new schedule representation.
author samer
date Sat, 22 Dec 2012 16:17:51 +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