view general/algo/product_it.m @ 42:ae596261e75f

Various fixes and development to audio handling
author samer
date Tue, 02 Dec 2014 14:51:13 +0000
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