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

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents e44f49929e56
children
rev   line source
samer@4 1 % tail_feval - Call function with tail recursion
samer@4 2 %
samer@4 3 % tail_feval :: (A{1:N}->rthunk(B{1:M}), A{1:N} -> B{1:M}.
samer@4 4 %
samer@4 5 % rthunk(B{1:M}) ::=
samer@4 6 % exists C{1:L} . cell { C{1:L} -> rthunk(B{1::}), C{1:L} }.
samer@4 7 % | cell { {0}, cell { B{1:L} } }
samer@4 8 function varargout=tail_feval(fn,varargin)
samer@4 9 ret=fn(varargin{:});
samer@4 10 while ~isnumeric(ret{1})
samer@4 11 ret=feval(ret{1},ret{2}{:});
samer@4 12 end
samer@4 13 varargout=ret{2}(1:nargout);
samer@4 14 end
samer@4 15
samer@4 16