HACK: New Gen operators: zip, interleave
authorMike Curtiss <mcurtiss@fb.com>
Sat, 2 Mar 2013 06:27:56 +0000 (22:27 -0800)
committerOwen Yamauchi <oyamauchi@fb.com>
Mon, 3 Jun 2013 19:23:28 +0000 (12:23 -0700)
commitc1c28d91824242c8fb8d792b63e0072d078b85c8
treeac7263d58dd88351f3adadacf72f193842f96788
parent22286705a74596d98b2bf200cef47afb3571844e
HACK: New Gen operators: zip, interleave

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
folly/experimental/CombineGen-inl.h [new file with mode: 0644]
folly/experimental/CombineGen.h [new file with mode: 0644]
folly/experimental/Gen-inl.h
folly/experimental/test/GenTest.cpp