Mercurial > hg > ishara
diff general/funutils/foreach.m @ 4:e44f49929e56
Adding reorganised general toolbox, now in several subdirectories.
author | samer |
---|---|
date | Sat, 12 Jan 2013 19:21:22 +0000 |
parents | |
children | 45aaf9b2d7b0 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/general/funutils/foreach.m Sat Jan 12 19:21:22 2013 +0000 @@ -0,0 +1,15 @@ +function foreach(f,X,varargin) +% foreach - do an action for each element in a cell array in order +% +% foreach :: (A->action), {[N]->A} -> action. +% foreach :: (A->action), {[N]->A}, options {} -> action. +% +% Takes the same options as iterate. + + iterate(@g,X,varargin{:}); + + function x=g(x) + f(x{1}); + x=x(2:end); + end +end