@@ -43,14 +43,31 @@ sealed trait Tuple extends Any {
43
43
inline def zip [This >: this .type <: Tuple , T2 <: Tuple ](t2 : T2 ): Zip [This , T2 ] =
44
44
DynamicTuple .dynamicZip(this , t2)
45
45
46
- /** Called on a tuple `(a1, ..., an)`, returns a new tuple `(f(a1), ..., f(an))`.
47
- * The result is typed as `(F[A1], ..., F[An])` if the tuple type is fully known.
48
- * If the tuple is of the form `a1 *: ... *: Tuple` (that is, the tail is not known
49
- * to be the cons type.
50
- */
46
+ /** Called on a tuple `(a1, ..., an)`, returns a new tuple `(f(a1), ..., f(an))`.
47
+ * The result is typed as `(F[A1], ..., F[An])` if the tuple type is fully known.
48
+ * If the tuple is of the form `a1 *: ... *: Tuple` (that is, the tail is not known
49
+ * to be the cons type.
50
+ */
51
51
inline def map [F [_]](f : [t] => t => F [t]): Map [this .type , F ] =
52
52
DynamicTuple .dynamicMap(this , f)
53
53
54
+ /** Given a tuple `(a1, ..., am)`, returns the tuple `(a1, ..., an)` consisting
55
+ * of its first n elements.
56
+ */
57
+ inline def take [This >: this .type <: Tuple ](n : Int ): Take [This , n.type ] =
58
+ DynamicTuple .dynamicTake[This , n.type ](this , n)
59
+
60
+
61
+ /** Given a tuple `(a1, ..., am)`, returns the tuple `(an+1, ..., am)` consisting
62
+ * all its elements except the first n ones.
63
+ */
64
+ inline def drop [This >: this .type <: Tuple ](n : Int ): Drop [This , n.type ] =
65
+ DynamicTuple .dynamicDrop[This , n.type ](this , n)
66
+
67
+ /** Given a tuple `(a1, ..., am)`, returns a pair of the tuple `(a1, ..., an)`
68
+ * consisting of the first n elements, and the tuple `(an+1, ..., am)` consisting
69
+ * of the remaining elements.
70
+ */
54
71
inline def splitAt [This >: this .type <: Tuple ](n : Int ): Split [This , n.type ] =
55
72
DynamicTuple .dynamicSplitAt[This , n.type ](this , n)
56
73
}
0 commit comments