When a sequential repetition of exactly the same form of code occurs, I prefer to use a data-based approach:
let verbExStrings = [ (k12VerbEx, "K - 12") (twoYearCollegeVerbEx, "2 Year College") (universityVerbEx, "University") (privateSchoolVerbEx, "Private / Charter School") ] let newInst x = verbExStrings |> List.tryPick (fun (verbEx, string) -> if isMatch x verbEx then Some string else None) |> function Some x -> x | _ -> "Other"
The advantage of this approach is that raw data ( verbExStrings ) can come in handy in other places and are not tied to your code implementation.
TheQuickBrownFox
source share