view general/funutils/@function_handle/lt.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents c388f1c70669
children
line wrap: on
line source
% lt - select inputs to function
%
% lt :: (A{1:N}=>B{:}), I:[[N]->natural] -> (C{:}=>B{:}) :- C(I)==A(1:N).
%
% f<[i,j,k...] is a function which takes any number of arguments
% but passes only the ith,jth,kth etc arguments to f, returning
% any values from f.

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

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