function g=gt(f,I,nin)
	if nargin<3, nin=nargin(f); end
	nout=length(I); MI=max(I);
	fns = { @q11, @q1n; @qn1, @qnn };
	g=fns{acount(nin,1),acount(nout,1)};

	function y=q11(x), [rets{1:MI}]=f(x); y=rets{I}; end
	function y=qn1(varargin), [rets{1:MI}]=f(varargin{:}); y=rets{I}; end
	function varargout=q1n(x), [rets{1:MI}]=f(x); varargout=rets(I); end
	function varargout=qnn(varargin), [rets{1:MI}]=f(varargin{:}); varargout=rets(I); end
end

