Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. // List.zip/zipWith
  2. final Option<String> option = Option.of("value");
  3. final Either<String, String> either = Either.right("yay");
  4. final Iterator<Integer> integers = Iterator.tabulate(5, value -> value + 1);
  5.  
  6. final List<Tuple2<Integer, String>> zipped = integers.zip(either);
  7. final List<Tuple3<Integer, String, String>> zipped3 = zipped
  8. .zip(option)
  9.   .map(e -> Tuple.of(e._1._1, e._1._2, e._2));
  10.  
  11. //the same with for-comprehension
  12. final Iterator<Tuple3<Integer, String, String>> combined = API.For(
  13. integers,
  14.   either,
  15.   option
  16. )
  17.   .yield(Tuple::of);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement