view general/algo/product_it.m @ 61:eff6bddf82e3 tip

Finally implemented perceptual brightness thing.
author samer
date Sun, 11 Oct 2015 10:20:42 +0100
parents f7fb679637ff
children
line wrap: on
line source
function h=product_it(f,g)
% product_it- compose two iterators to run in parallel
%
% product_it::
%    iterator(A) ~'first iterator transformer and initial value',
%    iterator(B) ~'second iterator transformer and initial value',
% -> iterator(cell {A,B}) ~'combined iterator'.
%
% The state transformer function returns [] to signal termination
% if EITHER of the sub-transformer functions returns [].

   ff=f{1}; gg=g{1};
   h={@prodit,{f{2},g{2}}};

   function h=prodit(s)
      s1=ff(s{1});
      s2=gg(s{2});
      if isempty(s1) || isempty(s2)
         h=[];
      else
         h={s1,s2};
      end
   end
end