annotate general/funutils/bind.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents fbc0540a9208
children
rev   line source
samer@4 1 % bind - Create a partially applied function
samer@4 2 %
samer@12 3 % bind ::
samer@12 4 % func(A{1}, ..., A{N}->B{1:L}) ~'func from N inputs to L outputs',
samer@12 5 % A{1}, ..., A{M} ~'M<=N input arguments of the correct types'
samer@12 6 % -> func(A{M+1}, ..., A{N}->B{1:L}) ~'func from remaining arguments to returns'.
samer@12 7 %
samer@4 8 % BIND(fn,a1,a2,...)
samer@4 9 % If fn is an ordinary function, the parameters a1, a2 etc
samer@4 10 % are bound as the first few arguments
samer@4 11 %
samer@4 12 % If fn is a function object as returned by FUNC, BIND, or PERM,
samer@4 13 % the given parameters are bound to the free slots of the function
samer@4 14 % and a new partially applied function is returned.
samer@4 15
samer@12 16 function cfn=bind(fn,varargin)
samer@4 17 if ischar(fn), fn=str2func(fn); end
samer@4 18 if ~isa(fn,'func'), fn=func(fn); end
samer@4 19 cfn=bind(fn,varargin{:});