@@ -33,9 +33,18 @@ sealed trait Tuple extends Any {
33
33
inline def size [This >: this .type <: Tuple ]: Size [This ] =
34
34
DynamicTuple .dynamicSize(this )
35
35
36
+ /** Given two tuples, `(A1, ..., An)` and `(B1, ..., Bn)`, returns a tuple
37
+ * `((A1, B1), ..., (An, Bn))`. If the two tuples have different sizes,
38
+ * the extra elements of the larger tuple will be disregarded.
39
+ */
36
40
inline def zip [This >: this .type <: Tuple , T2 <: Tuple ](t2 : T2 ): Zip [This , T2 ] =
37
41
DynamicTuple .dynamicZip(this , t2)
38
42
43
+ /** Called on a tuple `(A1, ..., An)`, returns a new tuple of type
44
+ * `(F[A1], ..., F[An])`. Each element of this tuple is the result
45
+ * of application of function `f` to the corresponding element of the
46
+ * callee tuple.
47
+ */
39
48
inline def map [F [_]](f : [t] => t => F [t]): Map [this .type , F ] =
40
49
DynamicTuple .dynamicMap(this , f)
41
50
}
@@ -79,6 +88,10 @@ object Tuple {
79
88
case h *: t => F [h] *: Map [t, F ]
80
89
}
81
90
91
+ /** Given two tuples, `(A1, ..., An)` and `(B1, ..., Bn)`, returns a tuple
92
+ * `((A1, B1), ..., (An, Bn))`. If the two tuples have different sizes,
93
+ * the extra elements of the larger tuple will be disregarded.
94
+ */
82
95
type Zip [T1 <: Tuple , T2 <: Tuple ] <: Tuple = (T1 , T2 ) match {
83
96
case (h1 *: t1, h2 *: t2) => (h1, h2) *: Zip [t1, t2]
84
97
case (Unit , _) => Unit
0 commit comments