LeetCode 729. My Calendar I in F#

URL

My Calendar I - LeetCode

Code

https://github.com/syohex/dotnet-study/tree/master/fsharp/leetcode/challenge/202409/my_calendar1/main.fsx

type MyCalendar =
    { Ranges: (int * int) list }

    static member Empty: MyCalendar = { Ranges = [] }

    static member Book (start: int) (end': int) (cal: MyCalendar) : (bool * MyCalendar) =
        let ok = cal.Ranges |> List.forall (fun (s, e) -> start >= e || end' < s)

        if ok then
            true,
            { cal with
                Ranges = (start, end') :: cal.Ranges }
        else
            false, cal