view arrows/amatrix.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
% amatrix - arrow to generate sequence by scanning through an array
%
% amatrix :: [[N,M]] -> arrow({},{[[N]]},1..M).
function o=amatrix(X)
	state=1;
	len=size(X,2);
	o=unfolder(@sfn1,state);

	function [x,S]=sfn(S)
		x=X(:,S);
		S=1+mod(S,len);
	end

	function [x,S]=sfn1(S)
		if S>len, error('ARROW:EOF','End of arrow sequence'); end
		x=X(:,S);
		S=S+1;
	end
end