Advertisement
Guest User

Untitled

a guest
Dec 8th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. package ss.week4;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. public class Util {
  7. public static <E> List<E> zip(
  8. List<E> l1, List<E> l2) {
  9. ArrayList<E> result = new ArrayList<E>();
  10. for (int i = 0; i < l1.size(); i++) {
  11. result.add(l1.get(i));
  12. result.add(l2.get(i));
  13. }
  14. return result;
  15. }
  16.  
  17. /**
  18. * signum function.
  19. * @param i the function argument
  20. * @return -1, 0 or 1 if the argument is negative, 0 or positive
  21. */
  22. public static int signum(int i) {
  23. if (i < 0) {
  24. return -1;
  25. } else if (i > 0) {
  26. return 1;
  27. } else {
  28. return 0;
  29. }
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement