anchor.diff:              end, List1),
      ?bool(Bool).
   
  -general_compare_any_1([#xqAtomicValue{} = V1|R1], Op, V2) ->
  +general_compare_any_1([V1|R1], Op, V2) when ?is_atomic(V1) ->
      case value_compare(Op,V1,V2) of
         ?bool(true) ->
            true;
  
positive.code:    general_compare(Op,L1,L2);
  general_compare(Op,L1,{array,L2}) -> 
     general_compare(Op,L1,L2);
  general_compare(Op,#xqAtomicValue{} = List1,#xqAtomicValue{} = List2) ->
     value_compare(Op,List1,List2);
  general_compare(Op,#xqRange{} = List1,#xqAtomicValue{} = V2) ->
     Bool = range_val_comp_any(Op, List1, V2),
     ?bool(Bool);
  general_compare(Op,#xqAtomicValue{} = V1,#xqRange{} = List2) ->
     Bool = range_val_comp_any(Op, V1, List2),
     ?bool(Bool);
  general_compare(Op,#xqRange{} = List1,#xqRange{} = List2) ->
     Bool = range_range_comp_any(Op, List1, List2),
     ?bool(Bool);
     
  general_compare(Op,#xqAtomicValue{} = V1,List2) when is_list(List2) ->
     Bool = general_compare_any_2(List2, Op, V1),
     ?bool(Bool);
  general_compare(Op, V1, List2) when is_list(List2), is_boolean(V1) ->
     Bool = general_compare_any_2(List2, Op, V1),
     ?bool(Bool);
  general_compare(Op,List1,#xqAtomicValue{} = V2) when is_list(List1) ->
     Bool = general_compare_any_1(List1, Op, V2),
     ?bool(Bool);
  general_compare(Op, List1, V2) when is_list(List1), is_boolean(V2) ->
     Bool = general_compare_any_1(List1, Op, V2),
     ?bool(Bool);
  general_compare(Op, V1, V2) when is_boolean(V1), is_boolean(V2) ->
     value_compare(Op, V1, V2);
  
  general_compare(Op, V1, #{nk := _} = V2) ->
     general_compare(Op, V1, xqerl_types:atomize(V2));
  
negative.code:    atomize_list([Seq]);
  atomize_list([]) -> [].
  
  numeric_type_val(I) when is_integer(I) ->
     {'xs:integer', I};
  numeric_type_val(I) when is_float(I) ->
     {'xs:double', I};
  numeric_type_val(#xqAtomicValue{type = TypeA0, value = neg_zero}) 
     when ?xs_numeric(TypeA0) ->
     {TypeA0, 0.0};
  numeric_type_val(#xqAtomicValue{type = TypeA0, value = ValA0}) 
     when ?xs_numeric(TypeA0) ->
     {TypeA0, ValA0};
  numeric_type_val(neg_zero) ->
     {'xs:double', 0.0};
  numeric_type_val(At) when At == nan;
                            At == neg_infinity;
                            At == infinity ->
     {'xs:double', At};
  numeric_type_val(_) ->
     ?err('XPTY0004').
  
  
  % returns: numeric
  numeric_add(A, B) -> 
     {TypeA, ValA} = numeric_type_val(A),
     {TypeB, ValB} = numeric_type_val(B),
     TypeC = if TypeA =:= TypeB -> TypeA;
                true ->
                   get_numeric_type(TypeA, TypeB)
  