view general/funutils/bind.m @ 42:ae596261e75f

Various fixes and development to audio handling
author samer
date Tue, 02 Dec 2014 14:51:13 +0000
parents fbc0540a9208
children
line wrap: on
line source
% bind - Create a partially applied function
% 
% bind :: 
%    func(A{1}, ..., A{N}->B{1:L})   ~'func from N inputs to L outputs',
%    A{1}, ..., A{M}                 ~'M<=N input arguments of the correct types'
% -> func(A{M+1}, ..., A{N}->B{1:L}) ~'func from remaining arguments to returns'.
%
% BIND(fn,a1,a2,...)
%    If fn is an ordinary function, the parameters a1, a2 etc
%    are bound as the first few arguments
%
%    If fn is a function object as returned by FUNC, BIND, or PERM,
%    the given parameters are bound to the free slots of the function
%    and a new partially applied function is returned.

function cfn=bind(fn,varargin)
if ischar(fn), fn=str2func(fn); end
if ~isa(fn,'func'), fn=func(fn); end
cfn=bind(fn,varargin{:});