• Mike Curtiss's avatar
    HACK: New Gen operators: zip, interleave · c1c28d91
    Mike Curtiss authored
    Summary:
    Zip: inspired by python's zip()
    o Combine a generator with the contents of a container to form
    a tuple.  Note that we combine with a container (and not
    another generator) because of a fundamental constraint
    in how control-flow in Generators works.  Containers give us 90%
    of the utility without all the hassle.  We could theoretically
    also add a version of zip where the extra source is generated
    concurrently in another thread.
    
    Interleave: similar to zip, but inspired by Clojure's interleave()
    o Instead of creating a tuple like zip, just flatten the values.
    
    Added some tuple creation/concatenation functions.  These are mostly
    meant as a way to enable zip'ing multiple containers together into an
    N-tuple. (My variadic-fu was not strong enough to get this working
    within a single Zip function).
    
    Test Plan: Added unit-tests
    
    Reviewed By: tjackson@fb.com
    
    FB internal diff: D740518
    c1c28d91
CombineGen.h 1.2 KB