annotate general/arrutils/forels.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents 03694e5c8365
children
rev   line source
samer@4 1 % forels - do an action for each element of an array in order
samer@4 2 %
samer@4 3 % forels ::
samer@4 4 % (A->action) ~'action to apply to each element',
samer@4 5 % [[Size]->A] ~'array of elements of type',
samer@13 6 % options iterate_options
samer@13 7 % => void.
samer@4 8 %
samer@4 9 % Note, the array can be multidimensional - the standard order
samer@4 10 % cycles through the earlier indices before the later ones, eg
samer@4 11 % rows, then columns, then slices etc.
samer@4 12
samer@13 13 function forels(f,X,varargin)
samer@4 14 N=numel(X);
samer@4 15 iterate(@g,1,varargin{:});
samer@4 16
samer@4 17 function i=g(i)
samer@4 18 if i>N, i=[]; else f(X(i)); i=i+1; end
samer@4 19 end
samer@4 20 end