I'm reconstructing the following statement.
IEnumerable<String>
input = ...,
filter = ...,
output = input.Where(filter.Contains(element));
For now, it works as supposed to but the words matched this way need to be exact. In the language of my customer there are a lot of conjugations and a requirement is posted to use joker characters ("dog" should match "dog", "doggy" and "dogmatic").
I've suggested the following change. Now sure, though, if it can be regarded as smooth for the eyes. Can someone suggest an improvement or is it as good as it gets?
IEnumerable<String>
input = ...,
filter = ...,
output = input.Where(word => filter.Any(head => word.StartsWith(head)))
I was considering IEqualityComparer implementation but that's only for objects of the same type, while my condition is on String contra IEnumerable.
StartsWith? Would "puppy" match in this case as well? Or what if they input "doggy"; should "dog" be a result as well? If everything is fine, I don't see a big issue about it being "smooth on the eyes"; it's not that bad. EDIT: If you want, you could move thefilter.Any(head => word.Startswith(head))into a separateFunc<string, bool>delegate and pass that in so you'd have:Func<string, bool> myConstraint = word => filter.Any(head => word.StartsWith(head)); output = input.Where(myConstraint);