anchor.diff:      let add (measurer : IMeasurer<_>) p (tree : Diet<'T>) : Diet<_> =
           addRec measurer p tree id
   
  +    /// Builds a new DIET from the elements of a sequence.
  +    let ofSeq (measurer : IMeasurer<_>) (sequence : seq<_>) : Diet<'T> =
  +        (Empty, sequence)
  +        ||> Seq.fold (fun tree el ->
  +            add measurer el tree)
  +
  +    /// Builds a new DIET from the elements of an F# list.
  +    let ofList (measurer : IMeasurer<_>) (list : _ list) : Diet<'T> =
  +        (Empty, list)
  +        ||> List.fold (fun tree el ->
  +            add measurer el tree)
  +
  +    /// Builds a new DIET from the elements of an array.
  +    let ofArray (measurer : IMeasurer<_>) (array : _[]) : Diet<'T> =
  +        (Empty, array)
  +        ||> Array.fold (fun tree el ->
  +            add measurer el tree)
  +
       /// Returns a new set with the specified range of values added to the set.
       /// No exception is thrown if any of the values are already contained in the set.
  -    let rec addRange (measurer : IMeasurer<_>) newRange (tree : Diet<'T>) : Diet<_> =
  +    let rec addRange (measurer : IMeasurer<_>) rangePQ (tree : Diet<'T>) : Diet<_> =
  +        let inline compare a b =
  +            measurer.Compare (a, b)
  +
           match tree with
           | AvlTree.Empty ->
  -            AvlTree.singleton newRange
  -        | AvlTree.Node (range, left, right, _) ->
  -            if measurer.Compare (newRange.MinValue, measurer.Previous range.MinValue) < 0 then
  -                AvlTree.join range (addRange measurer newRange left) right
  -            elif measurer.Compare (newRange.MinValue, measurer.Next range.MaxValue) > 0 then
  -                AvlTree.join range left (addRange measurer newRange right)
  +            AvlTree.singleton rangePQ
  +        | AvlTree.Node (rangeXY, left, right, _) ->
  +            if compare rangePQ.MaxValue (measurer.Previous rangeXY.MinValue) < 0 then
  +                AvlTree.join rangeXY (addRange measurer rangePQ left) right
  +            elif compare rangePQ.MinValue (measurer.Next rangeXY.MaxValue) > 0 then
  +                AvlTree.join rangeXY left (addRange measurer rangePQ right)
               else
                   let x', left' =
  -                    if measurer.Compare (newRange.MinValue, range.MinValue) >= 0 then range.MinValue, left
  -                    else find_del_left measurer newRange.MinValue left
  +                    if compare rangePQ.MinValue rangeXY.MinValue >= 0 then
  +                        rangeXY.MinValue, left
  +                    else find_del_left measurer rangePQ.MinValue left
   
                   let y', right' =
  -                    if measurer.Compare (newRange.MaxValue, range.MaxValue) <= 0 then range.MaxValue, right
  -                    else find_del_right measurer newRange.MaxValue right
  -
  -                AvlTree.join (Range (x', y')) left' right'
  +                    if compare rangePQ.MaxValue rangeXY.MaxValue <= 0 then
  +                        rangeXY.MaxValue, right
  +                    else find_del_right measurer rangePQ.MaxValue right
  +
  +                let rangeXY' = Range (x', y')
  +                AvlTree.join rangeXY' left' right'
   
       /// Returns a new set with the given element removed.
       /// No exception is thrown if the set doesn't contain the specified element.
  
positive.code:                     ((if cxa = 0 then l else addRange measurer (Range (rangeAB.MinValue, measurer.Previous x)) l),
                         true,
                         (if cbx = 0 then r else addRange measurer (Range (measurer.Next x, rangeAB.MaxValue)) r))
  
      /// Builds a new DIET from the elements of a sequence.
      let ofSeq (measurer : IMeasurer<_>) (sequence : seq<_>) : Diet<'T> =
          (Empty, sequence)
          ||> Seq.fold (fun tree el ->
              add measurer el tree)
  
      /// Builds a new DIET from the elements of an F# list.
      let ofList (measurer : IMeasurer<_>) (list : _ list) : Diet<'T> =
          (Empty, list)
          ||> List.fold (fun tree el ->
              add measurer el tree)
  
      /// Builds a new DIET from the elements of an array.
      let ofArray (measurer : IMeasurer<_>) (array : _[]) : Diet<'T> =
          (Empty, array)
          ||> Array.fold (fun tree el ->
              add measurer el tree)
  
      //
      let forall (predicate : 'T -> bool) (measurer : IMeasurer<_>) (t : Diet<'T>) =
          // OPTIMIZE : Rewrite this to short-circuit and return early
          // if we find a non-matching element.
          (measurer, true, t)
          |||> fold (fun state el ->
              state && predicate el)
  
  
  /// Character set implementation based on a Discrete Interval Encoding Tree.
  
negative.code:             cont (p, AvlTree.Empty)
          | AvlTree.Node (range, left, right, _) ->
              if measurer.Compare (p, measurer.Previous range.MinValue) < 0 then
                  find_del_right_rec measurer p left <| fun (p, left) ->
                      cont (p, AvlTree.join range left right)
              elif measurer.Compare (p, range.MaxValue) > 0 then
                  find_del_right_rec measurer p right cont
              else
  