LeetCode 729. My Calendar I in F#

URL

leetcode.com/problems/my-calendar-i

Code

github.com/syohex/dotnet-study/blob/master/..

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

    static member init() : MyCalendar = { Ranges = [] }

    static member book (start: int) (finish: int) (cal: MyCalendar) : (bool * MyCalendar) =
        let rec book' ranges start finish =
            match ranges with
            | [] -> true, { cal with Ranges = (start, finish) :: cal.Ranges }
            | (s, e) :: rest ->
                if s < finish && start < e then
                    false, cal
                else
                    book' rest start finish

        book' cal.Ranges start finish