anchor.diff:          | None ->
               raise <| System.Collections.Generic.KeyNotFoundException ()
   
  +    //
  +    [<CompiledName("MapPartition")>]
  +    let mapPartition (partitioner : 'T -> Choice<'U, 'V>) set =
  +        // Preconditions
  +        checkNonNull "set" set
  +
  +        // OPTIMIZATION : If the set is empty return immediately.
  +        if Set.isEmpty set then
  +            Set.empty, Set.empty
  +        else
  +            let mutable resultSet1 = Set.empty
  +            let mutable resultSet2 = Set.empty
  +
  +            for el in set do
  +                match partitioner el with
  +                | Choice1Of2 value ->
  +                    resultSet1 <- Set.add value resultSet1
  +                | Choice2Of2 value ->
  +                    resultSet2 <- Set.add value resultSet2
  +
  +            resultSet1, resultSet2
  +
  +    /// <summary>Computes the exclusive disjunction ("exclusive-or") of two sets.</summary>
  +    /// <remarks>
  +    /// The exclusive disjunction ("exclusive-or") operation creates
  +    /// a new set whose elements belong to exactly one (1) of the input sets.
  +    /// </remarks>
  +    [<CompiledName("ExclusiveOr")>]
  +    let xor (set1 : Set<'T>) (set2 : Set<'T>) : Set<'T> =
  +        // Preconditions
  +        checkNonNull "set1" set1
  +        checkNonNull "set2" set2
  +
  +        // OPTIMIZATION : If either set is empty return immediately.
  +        if Set.isEmpty set1 then
  +            set2
  +        elif Set.isEmpty set2 then
  +            set1
  +        else
  +            // OPTIMIZE : Check to see which set is larger and take
  +            // an optimized code path depending on the result.
  +            // For now, we assume 'set1' is the larger of the two sets.
  +
  +            // Remove the elements in set2 from set1.
  +            let set1' = Set.difference set1 set2
  +
  +            // Remove the elements in set1 from set2.
  +            // We use set1' instead of set1' because it is a subset of set1
  +            // and having fewer elements makes this operation faster.
  +            let set2' = Set.difference set2 set1'
  +
  +            // The XOR is the union of the two results.
  +            Set.union set1' set2'
  +
  +    /// The Cartesian product of two sets.
  +    [<CompiledName("Cartesian")>]
  +    let cartesian (set1 : Set<'T>) (set2 : Set<'U>) =
  +        // Preconditions
  +        checkNonNull "set1" set1
  +        checkNonNull "set2" set2
  +
  +        // OPTIMIZATION : If either set is empty return immediately.
  +        if Set.isEmpty set1 || Set.isEmpty set2 then
  +            Set.empty
  +        else
  +            (Set.empty, set1)
  +            ||> Set.fold (fun product x ->
  +                (product, set2)
  +                ||> Set.fold (fun product y ->
  +                    Set.add (x, y) product))
  +
  +    //
  +    [<CompiledName("MapIntersect")>]
  +    let mapIntersect (mapping : 'T -> Set<'U>) set =
  +        // Preconditions
  +        checkNonNull "set" set
  +
  +        // OPTIMIZATION : If the set is empty return immediately.
  +        if Set.isEmpty set then
  +            Set.empty
  +        else
  +            // To compute the intersection, we must start with the mapped set
  +            // for the first element -- if we used a "standard" fold and started
  +            // with Set.empty, the result would always be Set.empty.
  +
  +            let minElement, set = extractMin set
  +            let mappedMinElement = mapping minElement
  +
  +            (mappedMinElement, set)
  +            ||> Set.fold (fun intersection el ->
  +                mapping el
  +                |> Set.intersect intersection)
  +
  +    //
  +    [<CompiledName("MapUnion")>]
  +    let mapUnion (mapping : 'T -> Set<'U>) set =
  +        // Preconditions
  +        checkNonNull "set" set
  +
  +        // OPTIMIZATION : If the set is empty return immediately.
  +        if Set.isEmpty set then
  +            Set.empty
  +        else
  +            (Set.empty, set)
  +            ||> Set.fold (fun union el ->
  +                mapping el
  +                |> Set.union union)
  +
  +
  +    //
  +    [<RequireQualifiedAccess>]
  +    module Cartesian =
  +        //
  +        [<CompiledName("Fold")>]
  +        let fold (folder : 'State -> 'T -> 'U -> 'State) state set1 set2 =
  +            // Preconditions
  +            checkNonNull "set1" set1
  +            checkNonNull "set2" set2
  +
  +            let folder = FSharpFunc<_,_,_,_>.Adapt folder
  +            
  +            (state, set1)
  +            ||> Set.fold (fun state x ->
  +                (state, set2)
  +                ||> Set.fold (fun state y ->
  +                    folder.Invoke (state, x, y)))
  +
  +        //
  +        [<CompiledName("FoldBack")>]
  +        let foldBack (folder : 'T -> 'U -> 'State -> 'State) set1 set2 state =
  +            // Preconditions
  +            checkNonNull "set1" set1
  +            checkNonNull "set2" set2
  +
  +            let folder = FSharpFunc<_,_,_,_>.Adapt folder
  +
  +            (set1, state)
  +            ||> Set.foldBack (fun x state ->
  +                (set2, state)
  +                ||> Set.foldBack (fun y state ->
  +                    folder.Invoke (x, y, state)))
  +
  +        //
  +        [<CompiledName("Iterate")>]
  +        let iter (action : 'T -> 'U -> unit) set1 set2 =
  +            // Preconditions
  +            checkNonNull "set1" set1
  +            checkNonNull "set2" set2
  +
  +            let action = FSharpFunc<_,_,_>.Adapt action
  +
  +            set1
  +            |> Set.iter (fun x ->
  +                set2
  +                |> Set.iter (fun y ->
  +                    action.Invoke (x, y)))
  +
  +        //
  +        [<CompiledName("Map")>]
  +        let map (mapping : 'T -> 'U -> 'V) set1 set2 =
  +            // Preconditions
  +            checkNonNull "set1" set1
  +            checkNonNull "set2" set2
  +
  +            let mapping = FSharpFunc<_,_,_>.Adapt mapping
  +            
  +            (Set.empty, set1)
  +            ||> Set.fold (fun mappedSet x ->
  +                (mappedSet, set2)
  +                ||> Set.fold (fun mappedSet y ->
  +                    let mapped = mapping.Invoke (x, y)
  +                    Set.add mapped mappedSet))
  +
  +        //
  +        [<CompiledName("Choose")>]
  +        let choose (chooser : 'T -> 'U -> 'V option) set1 set2 =
  +            // Preconditions
  +            checkNonNull "set1" set1
  +            checkNonNull "set2" set2
  +
  +            let chooser = FSharpFunc<_,_,_>.Adapt chooser
  +            
  +            (Set.empty, set1)
  +            ||> Set.fold (fun mappedSet x ->
  +                (mappedSet, set2)
  +                ||> Set.fold (fun mappedSet y ->
  +                    match chooser.Invoke (x, y) with
  +                    | None ->
  +                        mappedSet
  +                    | Some value ->
  +                        Set.add value mappedSet))
  +
   
   /// Additional functional operators on maps.
   [<RequireQualifiedAccess; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
   module Map =
  +    open System.Collections.Generic
  +
       /// Determines the number of items in the Map.
       let [<NoDynamicInvocation>] inline count (map : Map<'Key, 'Value>) =
           map.Count
   
  +    //
  +    let [<NoDynamicInvocation>] inline findOrDefault defaultValue key (map : Map<'Key, 'T>) =
  +        defaultArg (Map.tryFind key map) defaultValue
  +
  +    //
  +    [<CompiledName("Keys")>]
  +    let keys (map : Map<'Key, 'T>) =
  +        // Preconditions
  +        checkNonNull "map" map
  +
  +        (Set.empty, map)
  +        ||> Map.fold (fun keys key _ ->
  +            Set.add key keys)
  +
  +    //
  +    [<CompiledName("Values")>]
  +    let values (map : Map<'Key, 'T>) =
  +        // Preconditions
  +        checkNonNull "map" map
  +
  +        (Set.empty, map)
  +        ||> Map.fold (fun values _ value ->
  +            Set.add value values)
  +
  +    //
  +    let [<NoDynamicInvocation>] addKvp (kvp : KeyValuePair<'Key, 'T>) map =
  +        Map.add kvp.Key kvp.Value map
  +
  +    //
  +    [<CompiledName("FromKvpSequence")>]
  +    let ofKvpSeq (sequence : seq<KeyValuePair<'Key, 'T>>) =
  +        // Preconditions
  +        checkNonNull "sequence" sequence
  +
  +        (Map.empty, sequence)
  +        ||> Seq.fold (fun map kvp ->
  +            addKvp kvp map)
  +
  +    //
  +    [<CompiledName("FromKeys")>]
  +    let ofKeys (mapping : 'Key -> 'T) (set : Set<'Key>) : Map<'Key, 'T> =
  +        // Preconditions
  +        checkNonNull "set" set
  +
  +        // OPTIMIZATION : If the set is empty return immediately.
  +        if Set.isEmpty set then
  +            Map.empty
  +        else
  +            (Map.empty, set)
  +            ||> Set.fold (fun map key ->
  +                Map.add key (mapping key) map)
  +
  +    //
  +    [<CompiledName("FromValues")>]
  +    let ofValues (mapping : 'T -> 'Key) (set : Set<'T>) : Map<'Key, 'T> =
  +        // Preconditions
  +        checkNonNull "set" set
  +
  +        // OPTIMIZATION : If the set is empty return immediately.
  +        if Set.isEmpty set then
  +            Map.empty
  +        else
  +            (Map.empty, set)
  +            ||> Set.fold (fun map value ->
  +                Map.add (mapping value) value map)
  +
  +    //
  +    [<CompiledName("RemoveKeys")>]
  +    let removeKeys keys (map : Map<'Key, 'T>) =
  +        // Preconditions
  +        checkNonNull "keys" keys
  +        checkNonNull "map" map
  +
  +        // OPTIMIZATION : If either the key set or input map is empty return immediately.
  +        if Set.isEmpty keys then
  +            map
  +        elif Map.isEmpty map then
  +            Map.empty
  +        else
  +            (map, keys)
  +            ||> Set.fold (fun map key ->
  +                Map.remove key map)
  +
  +    //
  +    [<CompiledName("SelectKeys")>]
  +    let selectKeys keys (map : Map<'Key, 'T>) =
  +        // Preconditions
  +        checkNonNull "keys" keys
  +        checkNonNull "map" map
  +
  +        // OPTIMIZATION : If either the key set or input map is empty return immediately.
  +        if Set.isEmpty keys || Map.isEmpty map then
  +            Map.empty
  +        else
  +            map
  +            |> Map.filter (fun key _ ->
  +                Set.contains key keys)
  +
  +    //
  +    [<CompiledName("Choose")>]
  +    let choose (chooser : 'Key -> 'T -> 'U option) map =
  +        // Preconditions
  +        checkNonNull "map" map
  +
  +        // OPTIMIZATION : If the input map is empty return immediately.
  +        if Map.isEmpty map then
  +            Map.empty
  +        else
  +            let chooser = FSharpFunc<_,_,_>.Adapt chooser
  +
  +            (Map.empty, map)
  +            ||> Map.fold (fun chosenMap key value ->
  +                match chooser.Invoke (key, value) with
  +                | None ->
  +                    chosenMap
  +                | Some newValue ->
  +                    Map.add key newValue chosenMap)
  +
  +    //
  +    [<CompiledName("MapPartition")>]
  +    let mapPartition (partitioner : 'Key -> 'T -> Choice<'U, 'V>) map =
  +        // Preconditions
  +        checkNonNull "map" map
  +
  +        // OPTIMIZATION : If the map is empty return immediately.
  +        if Map.isEmpty map then
  +            Map.empty, Map.empty
  +        else
  +            let partitioner = FSharpFunc<_,_,_>.Adapt partitioner
  +
  +            let mutable resultMap1 = Map.empty
  +            let mutable resultMap2 = Map.empty
  +
  +            for kvp in map do
  +                match partitioner.Invoke (kvp.Key, kvp.Value) with
  +                | Choice1Of2 value ->
  +                    resultMap1 <- Map.add kvp.Key value resultMap1
  +                | Choice2Of2 value ->
  +                    resultMap2 <- Map.add kvp.Key value resultMap2
  +
  +            resultMap1, resultMap2
  +
       /// Combines two maps into a single map.
       /// Whenever a key exists in both maps, the first map's entry will be added to the result map.
  +    [<CompiledName("Union")>]
       let union (map1 : Map<'Key, 'T>) (map2 : Map<'Key, 'T>) : Map<'Key, 'T> =
           // Preconditions
           checkNonNull "map1" map1
  
positive.code:         if Set.isEmpty set then
              invalidArg "set" "The set is empty."
  
          let maxElement = Set.maxElement set
          let set = Set.remove maxElement set
          Set.foldBack reduction set maxElement
  
      //
  
negative.code:     /// read access while still providing O(n) lookup.
      let [<NoDynamicInvocation>] inline readonly (arr : 'T[]) =
          System.Array.AsReadOnly arr
  
      //
      let [<NoDynamicInvocation>] inline ofSet (set : Set<'T>) : 'T[] =
          Set.toArray set
  
      //
      let [<NoDynamicInvocation>] inline toSet (array : 'T[]) : Set<'T> =
          Set.ofArray array
  
      /// Applies a function to each element of the collection, threading an accumulator argument through the computation.
      /// The integer index passed to the function indicates the array index of the element being transformed.
  