view general/funutils/flip.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents fbc0540a9208
children
line wrap: on
line source
function g=flip(f)
% flip - Flip order of first two arguments to a function
%
% flip :: (A,B->C) -> (B,A->C).
% flip :: (A,B,D{1:N}->C) -> (B,A,D{1:N}->C).

if isa(f,'func'), 
	g=perm(f,[2,1]);
else
	if nargin(f)==2, f=@(a,b)f(b,a);
	else f=@(a,b,varargin)f(b,a,varargin{:});
	end
end