Skip to content

Instantly share code, notes, and snippets.

@priort

priort/PersistTheList8.kt

Last active Jul 12, 2019
Embed
What would you like to do?
fun <E> dropWhile(list: List<E>, f: (E) -> Boolean): List<E> {
tailrec fun loop(remaining: List<E>): List<E> =
when(remaining) {
is Empty -> remaining
is Cons -> if (f(remaining.head)) loop(remaining.tail) else remaining
}
return loop(list)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.