Mercurial > hg > ishara
view general/funutils/foldl.m @ 6:0ce3c2070089
Removed duplicate code and fixed doc in timed_action.
author | samer |
---|---|
date | Mon, 14 Jan 2013 14:33:37 +0000 |
parents | e44f49929e56 |
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