public class Utility2D extends Object
Modifier and Type | Method and Description |
---|---|
static List<Integer> |
interval(int a,
int b)
Returns a list containing the elements [min, min + 1, min + 2, ..., max]
where min is the smaller value of a and b, and max is the larger value of
a and b.
|
static double |
reciprocal(int x)
Returns the double value equal to 1 divided by x.
|
static List<Integer> |
zipper(List<Integer> s,
List<Integer> t)
Returns the zipper of two lists s and t without modifying
s or t.
|
public static double reciprocal(int x)
Utility2D.reciprocal(2) returns 0.5
x
- a valueArithmeticException
- if x is equal to zeropublic static List<Integer> interval(int a, int b)
Utility2D.interval(-3, 2) returns the list [-3, -2, -1, 0, 1, 2]
a
- one end of an intervalb
- the other end of an intervalpublic static List<Integer> zipper(List<Integer> s, List<Integer> t)
For example:
s t Test2I.zipper(s, t) --------------------------------------------- [1] [2] [1, 2] [5, 7] [6, 8] [5, 6, 7, 8] [1, 1, 1] [0, 0, 0] [1, 0, 1, 0, 1, 0] [] [10, 9, 8] [10, 9, 8] [-5, 7, 2] [99] [-5, 99, 7, 2]
s
- a non-null listt
- a non-null list