> For the complete documentation index, see [llms.txt](https://gold.gitbook.io/kotlin/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://gold.gitbook.io/kotlin/collections/generation-operations/partition.md).

# partition

리스트를 조건식에 맞게 나누어 Pair\<List\<T>, List\<T>> 의 형태로 리턴한다

```kotlin
public inline fun <T> Iterable<T>.partition(predicate: (T) -> Boolean):
Pair<List<T>, List<T>> {
    val first = ArrayList<T>()
    val second = ArrayList<T>()
    for (element in this) {
        if (predicate(element)) {
            first.add(element)
        } else {
            second.add(element)
        }
    }
    return Pair(first, second)
}


val list = listOf(1, 2, 3, 4, 5)
println(list.partition{ it % 2 == 0 })  // [2, 4], [1, 3, 5]
```
