view general/cellutils/cfold.m @ 53:3ba80c9914ff

Minor doc fix, added .class to .hgignore
author samer
date Mon, 02 Feb 2015 10:47:55 +0000
parents 3cedfd4549ef
children
line wrap: on
line source
function X=cfold(fn,x)
% fold - Fold combinator for cells
%
% fold :: (X,X->X), cells(A) -> X.
%
% This function applies an associative operator to a list of arguments,
% as if the list was written out with the operator between consecutive
% elements, eg fold(@plus,{1,2,3,4}) = 1+2+3+4.

if isempty(x), X={}; else X=cfoldl(fn,head(x),next(x)); end