% cscanl - scanl for cell arrays
%
% cscanl :: 
%    (S,X->S)   ~'scannning function',
%    S          ~'initial value',
%    {[N]->X}   ~'data to scan, sequence of length L'
% -> {[N]->S}.

function Y=cscanl(f,y,X,varargin)
	Y=cell(size(X));
	if nargin>3
		opts=prefs('draw',0,varargin{:});
		for i=1:size(X,2)
			y1=f(y,X{i});
			Y{i}=y1;
			if opts.draw, opts.plotfn(i,y,X{i},y1);  end
			optpause(opts);
			y=y1;
		end
	else
		for i=1:size(X,2), y=f(y,X{i}); Y{i}=y; end
	end
		

