anchor.diff:                  result <- Set.add (initializer i) result
               result
   
  +    //
  +    [<CompiledName("ExtractMinimum")>]
  +    let extractMin (set : Set<'T>) =
  +        // Preconditions
  +        checkNonNull "set" set
  +        if Set.isEmpty set then
  +            invalidArg "set" "The set is empty."
  +
  +        let minElement = Set.minElement set
  +        let set = Set.remove minElement set
  +        minElement, set
  +
  +    //
  +    [<CompiledName("ExtractMaximum")>]
  +    let extractMax (set : Set<'T>) =
  +        // Preconditions
  +        checkNonNull "set" set
  +        if Set.isEmpty set then
  +            invalidArg "set" "The set is empty."
  +
  +        let maxElement = Set.maxElement set
  +        let set = Set.remove maxElement set
  +        maxElement, set
  +
       /// Reduces elements in a set in order from the least (minimum) element
       /// to the greatest (maximum) element.
       [<CompiledName("Reduce")>]
  
positive.code: open LanguagePrimitives
  open OptimizedClosures
  open ExtCore
  
  
  //
  [<RequireQualifiedAccess; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
  module ResizeArray =
      open System.Collections.Generic
  
  
      //
      let [<NoDynamicInvocation>] inline length (resizeArray : ResizeArray<'T>) =
          resizeArray.Count
  
      //
      let [<NoDynamicInvocation>] inline add item (resizeArray : ResizeArray<'T>) =
          resizeArray.Add item
  
      //
      let [<NoDynamicInvocation>] inline toArray (resizeArray : ResizeArray<'T>) =
          resizeArray.ToArray ()
  
      //
      let [<NoDynamicInvocation>] inline ofArray (arr : 'T[]) : ResizeArray<'T> =
          ResizeArray (arr)
  
      //
      let [<NoDynamicInvocation>] inline ofSeq (sequence : seq<'T>) : ResizeArray<'T> =
          ResizeArray (sequence)
  
      //
      let [<NoDynamicInvocation>] inline get (resizeArray : ResizeArray<'T>) index =
          resizeArray.[index]
  
      //
      let [<NoDynamicInvocation>] inline set (resizeArray : ResizeArray<'T>) index value =
          resizeArray.[index] <- value
  
      //
      let [<NoDynamicInvocation>] inline sortInPlace<'T when 'T : comparison> (resizeArray : ResizeArray<'T>) =
          resizeArray.Sort ()
  
      //
      let [<NoDynamicInvocation>] inline sortInPlaceBy<'T, 'Key when 'Key : comparison>
              (projection : 'T -> 'Key) (resizeArray : ResizeArray<'T>) =
          resizeArray.Sort (fun x y ->
              compare (projection x) (projection y))
  
      //
      let [<NoDynamicInvocation>] inline sortInPlaceWith (comparer : 'T -> 'T -> int) (resizeArray : ResizeArray<'T>) =
          resizeArray.Sort (comparer)
  
      // TODO:
      // map, mapi
      // iter, iteri
      // fold, foldBack
      // reduce, reduceBack
      // exists, forall
      // find, tryFind
      // findIndex, tryFindIndex
      // pick, tryPick
      // choose
      // singleton
  
  
  /// Functional programming operators related to the System.Collections.Generic.IDictionary type.
  [<RequireQualifiedAccess; CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
  module Dict =
      open System.Collections.Generic
  
      /// Thread-safe functional programming operators for mutable instances of System.Collections.Generic.IDictionary.
      module Safe =
          /// Attempts to retrieve the value associated with the specified key.
          let tryFind k (d : IDictionary<'Key, 'T>) =
              match lock d <| fun () -> d.TryGetValue k with
              | false, _ -> None
              | true, v -> Some v
          
          /// Lookup an element in the Dictionary, raising KeyNotFoundException if
          /// the Dictionary does not contain an element with the specified key.
          let find k (d : IDictionary<'Key, 'T>) =
              lock d <| fun () -> d.[k]
  
          /// Adds a new entry to the Dictionary.
          let add k v (d : IDictionary<'Key, 'T>) =
              if d.IsReadOnly then
                  invalidOp "Cannot add an entry to a read-only dictionary."
              lock d <| fun () ->
                  d.Add (k, v)
  
          /// Updates an existing entry in the dictionary with a new value,
          /// raising KeyNotFoundException if the Dictionary does not
          /// contain an element with the specified key.
          let update k v (d : IDictionary<'Key, 'T>) =
              if d.IsReadOnly then
                  invalidOp "Cannot update an entry in a read-only dictionary."
              lock d <| fun () ->
                  if d.ContainsKey k then
                      d.[k] <- v
                  else
                      raise <| System.Collections.Generic.KeyNotFoundException ()
  
          /// Removes the entry with the specified key from the Dictionary,
          /// returning a value indicating the success of the operation.
          let remove (k : 'Key) (d : IDictionary<'Key, 'T>) =
              if d.IsReadOnly then
                  invalidOp "Cannot remove an entry from a read-only dictionary."
              lock d <| fun () ->
                  d.Remove k
  
          /// Updates the value of an entry (which has the specified key)
          /// in the Dictionary, or creates a new entry if one doesn't exist.
          /// If the Dictionary is read-only, an InvalidOperationException is raised.
          let updateOrAdd k v (d : IDictionary<'Key, 'T>) =
              if d.IsReadOnly then
                  invalidOp "Cannot update or add an entry to a read-only dictionary."
              lock d <| fun () ->
                  d.[k] <- v
  
          /// Creates an immutable copy of a Dictionary.
          /// The entries are shallow-copied to the created Dictionary; that is,
          /// reference-typed keys and values will reference the same instances as
          /// in the mutable Dictionary, so care should be taken when using mutable keys and values.
          let toImmutable (d : IDictionary<'Key, 'T>) =
              lock d <| fun () ->
                  d
                  |> Seq.map (fun kvp ->
                      kvp.Key, kvp.Value)
                  |> dict
  
  
      /// Views the keys of the Dictionary as a sequence.
      let [<NoDynamicInvocation>] inline keys (dictionary : IDictionary<'Key, 'T>) =
          dictionary.Keys :> IEnumerable<'Key>
  
      /// Views the values of the Dictionary as a sequence.
      let [<NoDynamicInvocation>] inline values (dictionary : IDictionary<'Key, 'T>) =
          dictionary.Values :> IEnumerable<'T>
  
      /// Determines whether the Dictionary is empty.
      let [<NoDynamicInvocation>] inline isEmpty (dictionary : IDictionary<'Key,'T>) =
          dictionary.Count = 0
  
      /// Gets the number of entries in the Dictionary.
      let [<NoDynamicInvocation>] inline count (dictionary : IDictionary<'Key, 'T>) =
          dictionary.Count
  
      /// Gets the number of entries in the Dictionary as an unsigned integer.
      let [<NoDynamicInvocation>] inline natCount (dictionary : IDictionary<'Key, 'T>) =
          Checked.uint32 dictionary.Count
  
      /// Creates a mutable dictionary with the specified capacity.
      let [<NoDynamicInvocation>] inline createMutable<'Key, 'T when 'Key : equality> (capacity : int) =
          System.Collections.Generic.Dictionary<'Key, 'T> (capacity)
  
      /// Determines whether the Dictionary contains an element with the specified key.
      let [<NoDynamicInvocation>] inline containsKey k (dictionary : IDictionary<'Key, 'T>) =
          dictionary.ContainsKey k
  
      /// Adds a new entry to the dictionary.
      let [<NoDynamicInvocation>] inline add k v (dictionary : IDictionary<'Key, 'T>) =
          dictionary.Add (k, v)
          dictionary
  
      /// Removes the entry with the specified key from the Dictionary.
      /// An exception is raised if the entry cannot be removed.
      let [<NoDynamicInvocation>] inline remove (k : 'Key) (dictionary : IDictionary<'Key, 'T>) =
          if dictionary.Remove k then dictionary
          else failwithf "Unable to remove the entry with the key '%O' from the dictionary." k
  
      /// Lookup an element in the Dictionary, raising KeyNotFoundException if
      /// the dictionary does not contain an element with the specified key.
      let [<NoDynamicInvocation>] inline find k (dictionary : IDictionary<'Key, 'T>) =
          dictionary.[k]
              
      /// Attempts to retrieve the value associated with the specified key.
      let [<NoDynamicInvocation>] inline tryFind k (dictionary : IDictionary<'Key, 'T>) =
          match dictionary.TryGetValue k with
          | false, _ -> None
          | true, v -> Some v
  
      /// Updates the value of an entry (which has the specified key) in the Dictionary.
      /// Raises a KeyNotFoundException if the Dictionary does not contain an entry with the specified key.
      let update k v (dictionary : IDictionary<'Key, 'T>) =
          if dictionary.ContainsKey k then
              dictionary.[k] <- v
              dictionary
          else
              // TODO : Add an error message which includes the key.
              raise <| System.Collections.Generic.KeyNotFoundException ()
  
      /// Updates the value of an entry (which has the specified key) in
      /// the Dictionary, or creates a new entry if one doesn't exist.
      let [<NoDynamicInvocation>] inline updateOrAdd k v (dictionary : IDictionary<'Key, 'T>) =
          dictionary.[k] <- v
          dictionary    
  
      /// Applies the given function to successive entries, returning the
      /// first result where the function returns "Some(x)".
      let [<NoDynamicInvocation>] inline tryPick f (dictionary : IDictionary<'Key, 'T>) =
          dictionary
          |> Seq.tryPick (fun kvp ->
              f kvp.Key kvp.Value)
  
      /// Applies the given function to sucecssive entries, returning the
      /// first x where the function returns "Some(x)".
      let [<NoDynamicInvocation>] inline pick f (dictionary : IDictionary<'Key, 'T>) =
          match tryPick f dictionary with
          | Some res -> res
          | None ->
              // TODO : Add an error message which includes the key.
              raise <| System.Collections.Generic.KeyNotFoundException ()
  
      /// Views the Dictionary as a sequence of tuples.
      let toSeq (dictionary : IDictionary<'Key, 'T>) =
          dictionary
          |> Seq.map (fun kvp ->
              kvp.Key, kvp.Value)
  
      /// Applies the given function to each entry in the Dictionary.
      let iter (action : 'Key -> 'T -> unit) (dictionary : IDictionary<'Key, 'T>) =
          dictionary
          |> Seq.iter (fun kvp ->
              action kvp.Key kvp.Value)
  
      /// Returns a new Dictionary containing only the entries of the
      /// Dictionary for which the predicate returns 'true'.
      let filter (predicate : 'Key -> 'T -> bool) (dictionary : IDictionary<'Key, 'T>) =
          dictionary
          |> Seq.choose (fun kvp ->
              if predicate kvp.Key kvp.Value then
                  Some (kvp.Key, kvp.Value)
              else None)
          |> dict
  
      /// Builds a new Dictionary whose entries are the results of applying
      /// the given function to each element of the Dictionary.
      let map (f : 'Key -> 'T -> 'U) (dictionary : IDictionary<'Key, 'T>) =
          dictionary
          |> Seq.map (fun kvp ->
              kvp.Key, f kvp.Key kvp.Value)
          |> dict
  
      /// Applies the given function to each element of the Dictionary.
      /// Returns a Dictionary comprised of the results "x,y" for each
      /// entry where the function returns Some(y).
      let choose (f : 'Key -> 'T -> 'U option) (dictionary : IDictionary<'Key, 'T>) =
          dictionary
          |> Seq.choose (fun kvp ->
              f kvp.Key kvp.Value
              |> Option.map (fun x -> kvp.Key, x))
          |> dict
  
      /// Applies a function to each entry of the Dictionary,
      /// threading an accumulator argument through the computation.
      let fold f (state : 'State) (dictionary : IDictionary<'Key, 'T>) =
          (state, dictionary)
          ||> Seq.fold (fun state kvp ->
              f state kvp.Key kvp.Value)
  
      /// Splits the Dictionary into two Dictionaries, containing the entries
      /// for which the given predicate evaluates to "true" and "false".
      let partition p (dictionary : IDictionary<'Key, 'T>) =
          let t, f =
              ((Seq.empty, Seq.empty), dictionary)
              ||> fold (fun (trueSeq, falseSeq) k v ->
                  if p k v then
                      (Seq.append trueSeq (Seq.singleton (k, v)), falseSeq)
                  else
                      (trueSeq, Seq.append falseSeq (Seq.singleton (k, v))))
  
          dict t, dict f
  
      //
      let readonly (dictionary : IDictionary<'Key, 'T>) =
          dict <| toSeq dictionary
  
  
  /// Additional functional operators on sequences.
  
negative.code:         Array.blit arr 0 expandedArr count arr.Length
          expandedArr
  
      //
      [<CompiledName("MapPartition")>]
      let mapPartition (partitioner : 'T -> Choice<'U1, 'U2>) array : 'U1[] * 'U2[] =
          // Preconditions
          checkNonNull "array" array
  
          // OPTIMIZATION : If the input array is empty, immediately return empty results.
          if Array.isEmpty array then
              Array.empty, Array.empty
          else
              // Use ResizeArrays to hold the mapped values.
              let resultList1 = ResizeArray ()
              let resultList2 = ResizeArray ()
  
              // Partition the array, adding each element to the ResizeArray
              // specific by the partition function.
              array
              |> Array.iter (fun el ->
                  match partitioner el with
                  | Choice1Of2 value ->
                      resultList1.Add value
                  | Choice2Of2 value ->
                      resultList2.Add value)
  
              // Convert the ResizeArrays to arrays and return them.
              resultList1.ToArray (),
              resultList2.ToArray ()
  
      //
      [<CompiledName("MapPartition")>]
      let mapPartition3 (partitioner : 'T -> Choice<'U1, 'U2, 'U3>) array : 'U1[] * 'U2[] * 'U3[] =
          // Preconditions
          checkNonNull "array" array
  
          // OPTIMIZATION : If the input array is empty, immediately return empty results.
          if Array.isEmpty array then
              Array.empty, Array.empty, Array.empty
          else
              // Use ResizeArrays to hold the mapped values.
              let resultList1 = ResizeArray ()
              let resultList2 = ResizeArray ()
              let resultList3 = ResizeArray ()
  
              // Partition the array, adding each element to the ResizeArray
              // specific by the partition function.
              array
              |> Array.iter (fun el ->
                  match partitioner el with
                  | Choice1Of3 value ->
                      resultList1.Add value
                  | Choice2Of3 value ->
                      resultList2.Add value
                  | Choice3Of3 value ->
                      resultList3.Add value)
  
              // Convert the ResizeArrays to arrays and return them.
              resultList1.ToArray (),
              resultList2.ToArray (),
              resultList3.ToArray ()
  
      // TODO :
      // foldBacki
      // foldPairs, foldBackPairs
      // derive    // takes a 'T -> 'T -> 'T like reduce, but only performs one step; used to perform 'divided differences'
  
  
  //
  