Untitled

mail@pastecode.io avatar
unknown
fsharp
3 years ago
655 B
2
Indexable
Never
    
    let getOneByLength ls (len: int) = getByLength ls len |> List.exactlyOne

    let diff xs ys =
        Set.difference (Set.ofList xs) (Set.ofList ys)
        |> Set.toList

    let intersection xs ys =
        Set.intersect (Set.ofList xs) (Set.ofList ys)
        |> Set.toList

    let exactlyN n xs =
        let len = List.length xs

        match len with
        | len when len = n -> xs
        | len -> failwithf $"tried getting exactly %A{len} from %A{xs}"

    let seven = getOneByLength xs 3
    let one = getOneByLength xs 2
    let four = getOneByLength xs 4

    let segment1 = diff seven one |> List.exactlyOne