% vercat - function combinator, f&g (...) = f(...); return g(...)
%
% and ::
%    (A{:} => B{:}),
%    (A{:} => C{:})
% -> (A{:} => C{:}).
%
% and ::
%    (A{1:N} => B{:}),
%    (A{1:N} => C{1:M}),
%    N:natural,
%    M:natural
% -> (A{1:N} => C{1:M}).
function h=vercat(varargin)
	g=varargin{end};
	N=length(varargin)-1;
	fx=varargin(1:N);
	fns = { @q11, @q1n; @qn1, @qnn };
	h=fns{acount(nargin(g),1),acount(nargout(g),1)};
	function y=q11(x), callfx1(x); y=g(x); end
	function y=qn1(varargin), callfxn(varargin); y=g(varargin{:}); end
	function varargout=q1n(x), callfx1(x); [varargout{1:nargout}]=g(x); end
	function varargout=qnn(varargin), callfxn(varargin); [varargout{1:nargout}]=g(varargin{:}); end

	function callfx1(x), for i=1:N, fx{i}(x); end; end
	function callfxn(args), for i=1:N, fx{i}(args{:}); end; end
end
