LeetCode 2425. Bitwise XOR of All Pairings in F#

URL

Bitwise XOR of All Pairings - LeetCode

Code

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

let xorAllNums (nums1: int list) (nums2: int list) : int =
    let e1 = List.reduce (fun a b -> a ^^^ b) nums1
    let e2 = List.reduce (fun a b -> a ^^^ b) nums2

    match List.length nums1 % 2, List.length nums2 % 2 with
    | 0, 0 -> 0
    | 1, 0 -> e2
    | 0, 1 -> e1
    | 1, 1 -> e1 ^^^ e2
    | _ -> failwith "never reach here"