I had to read the question a few times to understand it. My understand is that you want to filter a list of file paths by a list of exclusions--with "log4net" being an example of an exclusion.
I'd go something like this, taking advantage of List.exists:
let excludePaths (pathsToExclude : string list) (path: string) =
pathsToExclude |> List.exists (fun exPath -> path.Contains(exPath)) |> not
This implementation can actually curry the labda function fun exPath -> path.Contains(exPath)
into simply path.Contains
since the method takes a single argument, which would give us:
let excludePaths (pathsToExclude : string list) (path: string) =
pathsToExclude |> List.exists path.Contains |> not
Currying (the F# formal term is partial application) can also be put to use here to bind an argument to the function. To create a check for "log4net", you can simply do this:
let nugetExclusions = ["log4net"]
let excludeNuget = excludePaths nugetExclusions
Just add all of the nuget paths you need to exclude from the list.
Since you are comparing paths contains
doesn't have a case-insensitive overload. At least not out of the box. You can add an extension function to string, though. A C# implementation is here on SO.
Here's a F# implementation of the extension method (note that I made this with a small-case contains--F# functions and overloads don't mix):
type System.String with
member x.contains (comp:System.StringComparison) str =
x.IndexOf(str,comp) >= 0
With this type extension in place we can change the excludePaths
function to this (again, I'm currying the newly created contains
extension method:
let excludePaths (pathsToExclude : string list) (path: string) =
pathsToExclude
|> List.exists (path.contains StringComparison.OrdinalIgnoreCase))
|> not
I hope you continue to use F#.