fun main() {
val list = listOf(1, 2, 3, 4, 5)
if (list.isNotEmpty()) {
Nel(list[0], list.subList(1, list.lastIndex))
}
}
According to arrow documents, it seems be able to do it through Semigroup
or Monad binding
.
However, there is no code to replace List
with NonEmptyList
.
Is there a better way to replace List
withNonEmptyList
without using subList
?