Skip to content

Instantly share code, notes, and snippets.

@jacquesgiraudel
Last active September 1, 2018 15:10
Show Gist options
  • Save jacquesgiraudel/247edb8e7147bc2afc96c5e104f8da75 to your computer and use it in GitHub Desktop.
Save jacquesgiraudel/247edb8e7147bc2afc96c5e104f8da75 to your computer and use it in GitHub Desktop.
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