annotate general/cellutils/cfold.m @ 44:3cedfd4549ef

Code added since initial check in.
author samer
date Tue, 13 Jan 2015 14:03:17 +0000
parents
children
rev   line source
samer@44 1 function X=cfold(fn,x)
samer@44 2 % fold - Fold combinator for cells
samer@44 3 %
samer@44 4 % fold :: (X,X->X), cells(A) -> X.
samer@44 5 %
samer@44 6 % This function applies an associative operator to a list of arguments,
samer@44 7 % as if the list was written out with the operator between consecutive
samer@44 8 % elements, eg fold(@plus,{1,2,3,4}) = 1+2+3+4.
samer@44 9
samer@44 10 if isempty(x), X={}; else X=cfoldl(fn,head(x),next(x)); end