zip

infix fun <T, R> Array<out T>.zip(other: Array<out R>): List<Pair<T, R>>(source)
infix fun <R> ByteArray.zip(other: Array<out R>): List<Pair<Byte, R>>(source)
infix fun <R> ShortArray.zip(other: Array<out R>): List<Pair<Short, R>>(source)
infix fun <R> IntArray.zip(other: Array<out R>): List<Pair<Int, R>>(source)
infix fun <R> LongArray.zip(other: Array<out R>): List<Pair<Long, R>>(source)
infix fun <R> FloatArray.zip(other: Array<out R>): List<Pair<Float, R>>(source)
infix fun <R> DoubleArray.zip(other: Array<out R>): List<Pair<Double, R>>(source)
infix fun <R> BooleanArray.zip(other: Array<out R>): List<Pair<Boolean, R>>(source)
infix fun <R> CharArray.zip(other: Array<out R>): List<Pair<Char, R>>(source)
infix fun ByteArray.zip(other: ByteArray): List<Pair<Byte, Byte>>(source)
infix fun IntArray.zip(other: IntArray): List<Pair<Int, Int>>(source)
infix fun LongArray.zip(other: LongArray): List<Pair<Long, Long>>(source)
infix fun CharArray.zip(other: CharArray): List<Pair<Char, Char>>(source)

Returns a list of pairs built from the elements of this array and the other array with the same index. The returned list has length of the shortest collection.

Since Kotlin

1.0

Samples


fun main() { 
   //sampleStart 
   val listA = listOf("a", "b", "c")
val listB = listOf(1, 2, 3, 4)
println(listA zip listB) // [(a, 1), (b, 2), (c, 3)] 
   //sampleEnd
}

inline fun <T, R, V> Array<out T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V>(source)
inline fun <R, V> ByteArray.zip(other: Array<out R>, transform: (a: Byte, b: R) -> V): List<V>(source)
inline fun <R, V> ShortArray.zip(other: Array<out R>, transform: (a: Short, b: R) -> V): List<V>(source)
inline fun <R, V> IntArray.zip(other: Array<out R>, transform: (a: Int, b: R) -> V): List<V>(source)
inline fun <R, V> LongArray.zip(other: Array<out R>, transform: (a: Long, b: R) -> V): List<V>(source)
inline fun <R, V> FloatArray.zip(other: Array<out R>, transform: (a: Float, b: R) -> V): List<V>(source)
inline fun <R, V> DoubleArray.zip(other: Array<out R>, transform: (a: Double, b: R) -> V): List<V>(source)
inline fun <R, V> BooleanArray.zip(other: Array<out R>, transform: (a: Boolean, b: R) -> V): List<V>(source)
inline fun <R, V> CharArray.zip(other: Array<out R>, transform: (a: Char, b: R) -> V): List<V>(source)

Returns a list of values built from the elements of this array and the other array with the same index using the provided transform function applied to each pair of elements. The returned list has length of the shortest collection.

Since Kotlin

1.0

Samples


fun main() { 
   //sampleStart 
   val listA = listOf("a", "b", "c")
val listB = listOf(1, 2, 3, 4)
val result = listA.zip(listB) { a, b -> "$a$b" }
println(result) // [a1, b2, c3] 
   //sampleEnd
}

infix fun <T, R> Array<out T>.zip(other: Iterable<R>): List<Pair<T, R>>(source)
infix fun <R> ByteArray.zip(other: Iterable<R>): List<Pair<Byte, R>>(source)
infix fun <R> ShortArray.zip(other: Iterable<R>): List<Pair<Short, R>>(source)
infix fun <R> IntArray.zip(other: Iterable<R>): List<Pair<Int, R>>(source)
infix fun <R> LongArray.zip(other: Iterable<R>): List<Pair<Long, R>>(source)
infix fun <R> FloatArray.zip(other: Iterable<R>): List<Pair<Float, R>>(source)
infix fun <R> DoubleArray.zip(other: Iterable<R>): List<Pair<Double, R>>(source)
infix fun <R> BooleanArray.zip(other: Iterable<R>): List<Pair<Boolean, R>>(source)
infix fun <R> CharArray.zip(other: Iterable<R>): List<Pair<Char, R>>(source)

Returns a list of pairs built from the elements of this collection and other array with the same index. The returned list has length of the shortest collection.

Since Kotlin

1.0

Samples


fun main() { 
   //sampleStart 
   val listA = listOf("a", "b", "c")
val listB = listOf(1, 2, 3, 4)
println(listA zip listB) // [(a, 1), (b, 2), (c, 3)] 
   //sampleEnd
}

inline fun <T, R, V> Array<out T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V>(source)
inline fun <R, V> ByteArray.zip(other: Iterable<R>, transform: (a: Byte, b: R) -> V): List<V>(source)
inline fun <R, V> ShortArray.zip(other: Iterable<R>, transform: (a: Short, b: R) -> V): List<V>(source)
inline fun <R, V> IntArray.zip(other: Iterable<R>, transform: (a: Int, b: R) -> V): List<V>(source)
inline fun <R, V> LongArray.zip(other: Iterable<R>, transform: (a: Long, b: R) -> V): List<V>(source)
inline fun <R, V> FloatArray.zip(other: Iterable<R>, transform: (a: Float, b: R) -> V): List<V>(source)
inline fun <R, V> DoubleArray.zip(other: Iterable<R>, transform: (a: Double, b: R) -> V): List<V>(source)
inline fun <R, V> BooleanArray.zip(other: Iterable<R>, transform: (a: Boolean, b: R) -> V): List<V>(source)
inline fun <R, V> CharArray.zip(other: Iterable<R>, transform: (a: Char, b: R) -> V): List<V>(source)

Returns a list of values built from the elements of this array and the other collection with the same index using the provided transform function applied to each pair of elements. The returned list has length of the shortest collection.

Since Kotlin

1.0

Samples


fun main() { 
   //sampleStart 
   val listA = listOf("a", "b", "c")
val listB = listOf(1, 2, 3, 4)
val result = listA.zip(listB) { a, b -> "$a$b" }
println(result) // [a1, b2, c3] 
   //sampleEnd
}

inline fun <V> ByteArray.zip(other: ByteArray, transform: (a: Byte, b: Byte) -> V): List<V>(source)
inline fun <V> ShortArray.zip(other: ShortArray, transform: (a: Short, b: Short) -> V): List<V>(source)
inline fun <V> IntArray.zip(other: IntArray, transform: (a: Int, b: Int) -> V): List<V>(source)
inline fun <V> LongArray.zip(other: LongArray, transform: (a: Long, b: Long) -> V): List<V>(source)
inline fun <V> FloatArray.zip(other: FloatArray, transform: (a: Float, b: Float) -> V): List<V>(source)
inline fun <V> DoubleArray.zip(other: DoubleArray, transform: (a: Double, b: Double) -> V): List<V>(source)
inline fun <V> BooleanArray.zip(other: BooleanArray, transform: (a: Boolean, b: Boolean) -> V): List<V>(source)
inline fun <V> CharArray.zip(other: CharArray, transform: (a: Char, b: Char) -> V): List<V>(source)

Returns a list of values built from the elements of this array and the other array with the same index using the provided transform function applied to each pair of elements. The returned list has length of the shortest array.

Since Kotlin

1.0

Samples


fun main() { 
   //sampleStart 
   val listA = listOf("a", "b", "c")
val listB = listOf(1, 2, 3, 4)
val result = listA.zip(listB) { a, b -> "$a$b" }
println(result) // [a1, b2, c3] 
   //sampleEnd
}

infix fun <T, R> Iterable<T>.zip(other: Array<out R>): List<Pair<T, R>>(source)

Returns a list of pairs built from the elements of this collection and the other array with the same index. The returned list has length of the shortest collection.

Since Kotlin

1.0

Samples


fun main() { 
   //sampleStart 
   val listA = listOf("a", "b", "c")
val listB = listOf(1, 2, 3, 4)
println(listA zip listB) // [(a, 1), (b, 2), (c, 3)] 
   //sampleEnd
}

inline fun <T, R, V> Iterable<T>.zip(other: Array<out R>, transform: (a: T, b: R) -> V): List<V>(source)

Returns a list of values built from the elements of this collection and the other array with the same index using the provided transform function applied to each pair of elements. The returned list has length of the shortest collection.

Since Kotlin

1.0

Samples


fun main() { 
   //sampleStart 
   val listA = listOf("a", "b", "c")
val listB = listOf(1, 2, 3, 4)
val result = listA.zip(listB) { a, b -> "$a$b" }
println(result) // [a1, b2, c3] 
   //sampleEnd
}

infix fun <T, R> Iterable<T>.zip(other: Iterable<R>): List<Pair<T, R>>(source)

Returns a list of pairs built from the elements of this collection and other collection with the same index. The returned list has length of the shortest collection.

Since Kotlin

1.0

Samples


fun main() { 
   //sampleStart 
   val listA = listOf("a", "b", "c")
val listB = listOf(1, 2, 3, 4)
println(listA zip listB) // [(a, 1), (b, 2), (c, 3)] 
   //sampleEnd
}

inline fun <T, R, V> Iterable<T>.zip(other: Iterable<R>, transform: (a: T, b: R) -> V): List<V>(source)

Returns a list of values built from the elements of this collection and the other collection with the same index using the provided transform function applied to each pair of elements. The returned list has length of the shortest collection.

Since Kotlin

1.0

Samples


fun main() { 
   //sampleStart 
   val listA = listOf("a", "b", "c")
val listB = listOf(1, 2, 3, 4)
val result = listA.zip(listB) { a, b -> "$a$b" }
println(result) // [a1, b2, c3] 
   //sampleEnd
}