Last active
May 5, 2017 20:29
-
-
Save JorgeCastilloPrz/0985506cb9f88625b576eb47c2be964c to your computer and use it in GitHub Desktop.
imperative filter method for blog snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun <T> filter(l: List<T>, f: (T) -> Boolean): MutableList<T> { | |
val res = mutableListOf<T>() | |
l.forEach { if (f(it)) { res += it } } | |
return res | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment