view general/cellutils/cfoldr.m @ 58:ba866ae124c6

Now accepts single color index for all points.
author samer
date Fri, 09 Oct 2015 13:01:37 +0100
parents 03694e5c8365
children
line wrap: on
line source
function X=foldr(fn,e,args)
% foldr - Fold from the right for cell arrays
%
% This function applies an operator to a list of arguments,
% starting from the right, eg
% elements, eg foldr(@plus,0,{1,2,3,4}) = (1+(2+(3+(4+0)))).
%
% foldr :: 
%    (Y,X->X)	~'associative binary operator',
%    Y         ~'initial element',
%    {[N]->Y} ~'list (cell array) of arguments'
% -> Y.
X=e; for i=length(args):-1:1, X=fn(args{i},X); end