Created
September 17, 2018 15:49
-
-
Save Serchinastico/c32415481a73e2b462531d357e4d1d0f to your computer and use it in GitHub Desktop.
filter;map koan
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
// Return the set of cities the customers are from | |
fun Shop.getCitiesCustomersAreFrom(): Set<City> = customers.map { it.city }.toSet() | |
// Return a list of the customers who live in the given city | |
fun Shop.getCustomersFrom(city: City): List<Customer> = customers.filter { it.city == city } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment