annotate general/cellutils/@cell/foldl.m @ 13:03694e5c8365

Reorganised some high order list functions to correct class-based method dispatch; fixed some docs.
author samer
date Wed, 16 Jan 2013 12:12:34 +0000
parents 45aaf9b2d7b0
children
rev   line source
samer@4 1 function X=foldl(fn,e,args)
samer@4 2 % foldl - Fold fom the left combinator
samer@4 3 %
samer@4 4 % This function applies an associative operator to cell array,
samer@4 5 % starting from the left using the given starting element.
samer@4 6 % eg fold(@plus,0,{1,2,3,4}) = ((((0+1)+2)+3)+4).
samer@4 7 %
samer@4 8 % foldl ::
samer@4 9 % (X,Y->X) ~'associative binary operator',
samer@4 10 % X ~'initial element',
samer@4 11 % {[N]->Y} ~'list (cell array) of arguments (at least 2 elements)'
samer@4 12 % -> X.
samer@4 13 X=e; for i=1:length(args), X=fn(X,args{i}); end