anchor.diff:  //                    result
   //                | Some i ->
   //                    AvlTree.Join comparer i result stream''
  +
  +            assert (AvlTree.AvlInvariant result)
  +
  +            #if DEBUG
  +            let resultCount = count result
  +            Debug.Assert (
  +                resultCount >= minPossibleResultCount,
  +                sprintf "The result set should not contain fewer than %i elements, but it contains only %i elements."
  +                    minPossibleResultCount resultCount)
  +            Debug.Assert (
  +                resultCount <= maxPossibleResultCount,
  +                sprintf "The result set should not contain more than %i elements, but it contains %i elements."
  +                    maxPossibleResultCount resultCount)
  +            #endif
  +            result
  +
  +    /// Helper function for computing the intersection of two sets.
  +    let rec private inter' (input : CharDiet) head (stream : CharDiet) : CharDiet * (char * char) option * CharDiet =
  +        // Preconditions
  +        assert (AvlTree.Height input >= AvlTree.Height stream)
  +        assert (AvlTree.AvlInvariant input)
  +        assert (AvlTree.AvlInvariant stream)
  +
  +        match head, input with
  +        | None, _ ->
  +            Empty, None, Empty
  +        | _, Empty ->
  +            Empty, head, stream
  +        | Some (x, y), Node (left, right, (a, b), _) ->
  +            let left, head, stream =
  +                if x < a then
  +                    inter' left head stream
  +                else
  +                    Empty, head, stream
  +
  +            inter_helper (a, b) right left head stream
  +
  +    /// Helper function for computing the intersection of two sets.
  +    and private inter_helper (a, b) (right : CharDiet) (left : CharDiet) head stream =
  +        // Preconditions
  +        assert (AvlTree.AvlInvariant left)
  +        assert (AvlTree.AvlInvariant right)
  +        assert (AvlTree.AvlInvariant stream)
  +
  +        match head with
  +        | None ->
  +            left, None, Empty
  +        | Some (x, y) ->
  +            if y < a then
  +                match stream with
  +                | Empty ->
  +                    left, None, Empty
  +                | _ ->
  +                    AvlTree.TryExtractMin stream
  +                    ||> inter_helper (a, b) right left
  +            elif b < x then
  +                let right, head, stream = inter' right head stream
  +                AvlTree.Reroot (comparer, left, right), head, stream
  +            elif y >= clampedPred y b then
  +                let right, head, stream = inter' right head stream
  +                let right' = AvlTree.Join (comparer, left, right, (max x a, min y b))
  +                right', head, stream
  +            else
  +                let left = addRange (max x a, y) left
  +                inter_helper (succ y, b) right left head stream
  +
  +    /// Computes the intersection of the two sets.
  +    let rec intersect (input : CharDiet) (stream : CharDiet) : CharDiet =
  +        // Preconditions
  +        assert (AvlTree.AvlInvariant input)
  +        assert (AvlTree.AvlInvariant stream)
  +
  +        match input, stream with
  +        | Empty, _
  +        | _, Empty ->
  +            Empty
  +        | Node (_,_,_,inputHeight), Node(_,_,_,streamHeight)
  +            when streamHeight > inputHeight ->
  +            intersect stream input
  +        | _, _ ->
  +            #if DEBUG
  +            let inputCount = count input
  +            let streamCount = count stream
  +            /// The minimum possible number of elements in the resulting set.
  +            let minPossibleResultCount =
  +                min inputCount streamCount
  +            /// The maximum possible number of elements in the resulting set.
  +            let maxPossibleResultCount =
  +                inputCount + streamCount
  +            #endif
  +
  +            let result, _, _ =
  +                AvlTree.TryExtractMin stream
  +                ||> inter' input
  +            assert (AvlTree.AvlInvariant result)
   
               #if DEBUG
               let resultCount = count result
  
positive.code: 
      //
      let toList (tree : CharDiet) =
          ([], tree)
          ||> fold (fun list el ->
              el :: list)
  
      //
      let toArray (tree : CharDiet) =
          let elements = ResizeArray ()
          iter elements.Add tree
          elements.ToArray ()
  
      //
      let toSet (tree : CharDiet) =
          (Set.empty, tree)
          ||> fold (fun set el ->
              Set.add el set)
  
negative.code:     /// Applies the given accumulating function to all elements in a DIET.
      let foldBack (folder : char -> 'State -> 'State) (tree : CharDiet) (state : 'State) =
          // Preconditions
          assert (AvlTree.AvlInvariant tree)
  
          let folder = FSharpFunc<_,_,_>.Adapt folder
  
  