I don't know that pattern matching will do any miracles for you here. Here's one stab at it:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
#light

type Person =
    {   ID: int;
        Firstname: string;
        Lastname: string;
    }

let OtherLogic first last l = None

let BestMatch : string -> string -> Person list -> Person option =
    fun first last list ->
    match list |> List.filter (fun p -> p.Lastname = last) with
    | [] -> OtherLogic first last list
    | [x] -> Some x
    | list2 -> 
        match list2 |> List.filter (fun p -> p.Firstname = first) with
        | [x] -> Some x
        | _ -> OtherLogic first last list2
By on 12/4/2008 1:54 AM ()
IntelliFactory Offices Copyright (c) 2011-2012 IntelliFactory. All rights reserved.
Home | Products | Consulting | Trainings | Blogs | Jobs | Contact Us | Terms of Use | Privacy Policy | Cookie Policy
Built with WebSharper