intersectBy returns a subsequence of the first stream which
intersects with the second stream. Note that this is not a commutative
operation unlike a set intersection, because of duplicate elements in
the stream the order of the streams matters. This is similar to
intersectBy. Note that intersectBy is a special case of
innerJoin.
>>> f s1 s2 = Stream.fold Fold.toList $ Stream.intersectBy (==) (Stream.fromList s1) (Stream.fromList s2)
>>> f [1,3,4,4,5] [2,3,4,5,5]
[3,4,4,5]
First stream can be infinite, the second stream must be finite and
must be capable of multiple evaluations.
Space: O(n) where
n is the number of elements in the second
stream.
Time: O(m x n) where
m is the number of elements in the first
stream and
n is the number of elements in the second stream.
Pre-release