function [Y,x]=spanc(f,x)
% spanc - divide sequence using a test function
%
% spanc :: (A->bool), seq(A) -> {[N]->A}, seq(A).
%
% spanc f x = (seq2cell (takeWhile f x),dropWhile f x)
% Will not terminate if head segments turns out to be infinite.
%
% Note: this is like span but returns a cell array for the head sequence

if isempty(x), Y={}; return
else
	Y={};
	y=head(x);
	while f(y)
		Y=horzcat(Y,y);
		x=next(x);
		if isempty(x), break; end
		y=head(x);
	end
end
		
