You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
//infix fun <T> List<T>.intersectList(other: List<T>): List<T> {
13
+
// val intersection = arrayListOf<T>()
14
+
// for (element in this)
15
+
// if (element in other) intersection.add(element)
16
+
// return intersection
17
+
//}
18
+
19
+
/**
20
+
* Turns a list into a pair.
21
+
*/
22
+
fun <T> List<T>.makePair(): Pair<T, T> =if (size ==2) Pair(get(0), get(1)) elsethrowIllegalArgumentException("There must be exactly two elements to make a pair.")
23
+
24
+
/**
25
+
* Turns a list into a triple.
26
+
*/
27
+
fun <T> List<T>.makeTriple(): Triple<T, T, T> =if (size ==3) Triple(get(0), get(1), get(2)) elsethrowIllegalArgumentException("There must be exactly three elements to make a triple.")
28
+
29
+
/**
30
+
* Splits a string in two.
31
+
*
32
+
* @param delimiters One or more strings to be used as delimiters.
33
+
* @param ignoreCase `true` to ignore character case when matching a delimiter. By default `false`.
34
+
* @param limit The maximum number of substrings to return. Zero by default means no limit is set.
0 commit comments