annotate 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 |
rev |
line source |
samer@4
|
1 function g=flip(f)
|
samer@4
|
2 % flip - Flip order of first two arguments to a function
|
samer@4
|
3 %
|
samer@4
|
4 % flip :: (A,B->C) -> (B,A->C).
|
samer@4
|
5
|
samer@4
|
6 if isa(f,'func'),
|
samer@4
|
7 g=perm(f,[2,1]);
|
samer@4
|
8 else
|
samer@4
|
9 if nargin(f)==2, f=@(a,b)f(b,a);
|
samer@4
|
10 else f=@(a,b,varargin)f(b,a,varargin{:});
|
samer@4
|
11 end
|
samer@4
|
12 end
|
samer@4
|
13
|