Mercurial > hg > ishara
view general/funutils/forels.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 forels(f,X,varargin) % forels - do an action for each element of an array in order % % forels :: % (A->action) ~'action to apply to each element', % [[Size]->A] ~'array of elements of type', % options { % pause :: bool/0 % drawnow :: bool/1 % } ~'see ITERATE for more options' % -> action. % % Note, the array can be multidimensional - the standard order % cycles through the earlier indices before the later ones, eg % rows, then columns, then slices etc. N=numel(X); iterate(@g,1,varargin{:}); function i=g(i) if i>N, i=[]; else f(X(i)); i=i+1; end end end