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

