Last active
September 1, 2018 15:10
-
-
Save jacquesgiraudel/247edb8e7147bc2afc96c5e104f8da75 to your computer and use it in GitHub Desktop.
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
val findByTitle = {query: String -> {collection: MutableList<Movie> -> | |
val predicate = matches(query) | |
filter(predicate)(collection) | |
}} | |
val filter = {predicate: (Movie) -> Boolean -> {collection: List<Movie> -> | |
collection.filter(predicate) | |
}} | |
val matches = {query: String -> { movie: Movie -> | |
isInfixOf(query) (title(movie)) | |
}} | |
val title = {movie: Movie -> movie.title} | |
val isInfixOf = {query: String -> {string: String -> | |
string.contains(query) | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment