package com.pixelized.desktop.lwa.utils.extention

fun <T> List<T>.foldInto(size: Int): List<List<T>> = fold(
    initial = mutableListOf<MutableList<T>>(),
    operation = { acc, item ->
        if (acc.isEmpty() || acc.last().size == size) {
            acc.add(mutableListOf())
        }
        acc.also {
            it.last().add(item)
        }
    }
)