samer@4: % bind - Create a partially applied function samer@4: % samer@12: % bind :: samer@12: % func(A{1}, ..., A{N}->B{1:L}) ~'func from N inputs to L outputs', samer@12: % A{1}, ..., A{M} ~'M<=N input arguments of the correct types' samer@12: % -> func(A{M+1}, ..., A{N}->B{1:L}) ~'func from remaining arguments to returns'. samer@12: % samer@4: % BIND(fn,a1,a2,...) samer@4: % If fn is an ordinary function, the parameters a1, a2 etc samer@4: % are bound as the first few arguments samer@4: % samer@4: % If fn is a function object as returned by FUNC, BIND, or PERM, samer@4: % the given parameters are bound to the free slots of the function samer@4: % and a new partially applied function is returned. samer@4: samer@12: function cfn=bind(fn,varargin) samer@4: if ischar(fn), fn=str2func(fn); end samer@4: if ~isa(fn,'func'), fn=func(fn); end samer@4: cfn=bind(fn,varargin{:});