annotate sequences/@seq/foldl.m @ 36:9e7be347b3a0

Renamed sequence classes to avoid clashes with seq methods; Fixed default slicing dimension while retaining behaviour of window.m; Updated use of sequences in dsp/synth.
author samer
date Thu, 24 Jan 2013 14:51:23 +0000
parents 03694e5c8365
children beb8a3f4a345
rev   line source
samer@3 1 function x=foldl(fn,e,y,varargin)
samer@3 2 % foldl - Fold combinator for sequences
samer@3 3 %
samer@3 4 % This function applies an associative operator to a list of arguments,
samer@3 5 % starting from the left using the given starting element.
samer@3 6 %
samer@3 7 % foldl ::
samer@3 8 % (X,Y->X) ~'associative binary operator',
samer@3 9 % X ~'initial element',
samer@3 10 % seq(Y) ~'a lazy sequence'
samer@3 11 % -> X.
samer@3 12
samer@13 13 if iscell(y), x=cfoldl(fn,e,y); return; end
samer@3 14 if nargin<4,
samer@3 15 x=e;
samer@3 16 while ~isempty(y)
samer@3 17 x=fn(x,head(y));
samer@3 18 y=next(y);
samer@3 19 end
samer@3 20 else
samer@3 21 opts=prefs('quiet',1,varargin{:});
samer@3 22 x=e;
samer@3 23 while ~isempty(y)
samer@3 24 x=fn(x,head(y));
samer@3 25 y=next(y);
samer@3 26 if ~opts.quiet, fprintf('.'); end
samer@3 27 optpause(opts);
samer@3 28 end
samer@3 29 end