view general/funutils/flip.m @ 4:e44f49929e56

Adding reorganised general toolbox, now in several subdirectories.
author samer
date Sat, 12 Jan 2013 19:21:22 +0000
parents
children fbc0540a9208
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).

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