Mercurial > hg > ishara
view 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 |
line wrap: on
line source
function X=foldl(fn,e,args) % foldl - Fold fom the left combinator % % This function applies an associative operator to cell array, % starting from the left using the given starting element. % eg fold(@plus,0,{1,2,3,4}) = ((((0+1)+2)+3)+4). % % foldl :: % (X,Y->X) ~'associative binary operator', % X ~'initial element', % {[N]->Y} ~'list (cell array) of arguments (at least 2 elements)' % -> X. X=e; for i=1:length(args), X=fn(X,args{i}); end