Skip to content

Instantly share code, notes, and snippets.

@JorgeCastilloPrz
Last active May 5, 2017 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JorgeCastilloPrz/0985506cb9f88625b576eb47c2be964c to your computer and use it in GitHub Desktop.
Save JorgeCastilloPrz/0985506cb9f88625b576eb47c2be964c to your computer and use it in GitHub Desktop.
imperative filter method for blog snippet
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