Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
var findByTitle: (String) -> (MutableList<Movie>) -> List<Movie> =
{ query -> { collection ->
val predicate = matches(query)
filter(predicate)(collection)
}}
val filter: ((Movie) -> Boolean) -> (List<Movie>) -> List<Movie> =
{ predicate -> { collection ->
collection.filter(predicate)
}}
val matches: (String) -> (Movie) -> Boolean =
{ query -> { movie ->
isInfixOf(query) (title(movie))
}}
val title: (Movie) -> String =
{ movie -> movie.title}
val isInfixOf: (String) -> (String) -> Boolean =
{ query -> { string ->
string.contains(query)
}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment