% le - distribute cell argument to multiple in arguments
%
% le :: (A{1:N}=>B{:}), M:natural -> (cell {A{1:M}}, A{M+1:N} -> B{:}).
%
% f<=5 is a function which takes any number of arguments but where the first
% argument is assumed to be a cell array of M elements which are distributed
% to the first M arguments of f.

function g=le(f,I)
	if nargout(f)==1, g=@q1; else g=@qn; end

	function x=q1(varargin)
		args1=varargin{1};
		x=f(args1{1:I},varargin{2:end});
	end
	function varargout=qn(varargin)
		args1=varargin{1};
		[varargout{1:nargout}]=f(args1{1:I},varargin{2:end});
	end
end
