pub fn cmp_terms(a: LTerm, b: LTerm, exact: bool) -> Ordering {
  // Comparison might want to recurse, to avoid stack growth, do a switch here
  // and continue comparing. We grow `stack` instead of a CPU stack.
  let mut stack = Vec::<ContinueCompare>::new();
  let mut op = ContinueCompare::AnyType(a, b);

  loop {
    let eq_result = match op {
      ContinueCompare::AnyType(a1, b1) |
      ContinueCompare::Cons(a1, b1) => {
        cmp_terms_any_type(a1, b1, exact)
      },
    };

    match eq_result {
      EqResult::Concluded(result) if result == Ordering::Equal => {
        if stack.is_empty() {
          //println!("comparison {} {} concluded {:?}", a, b, result);
          return result
        } else {
          //println!("comparison {} {} got intermediate result {:?}", a, b, result);
          op = stack.pop().unwrap();
          continue
        } // stack not empty
      },

      EqResult::Concluded(result) => return result,

      // Nested terms may accidentally compare equal, to be able to return and
      // continue comparing upper level term, we store a `continue_op` on
      // `stack`.
      EqResult::CompareNested(a3, b3, continue_op) => {
        stack.push(continue_op);
        op = ContinueCompare::AnyType(a3, b3);
        continue
      },
    }
  }
}
/// Compare two terms for equality, fail if types are different even if
/// coercion is otherwise possible.
Compare two terms for equality, fail if types are different even if
coercion is otherwise possible.
Compare two terms for equality fail if types are different even if coercion is otherwise possible .
pub fn cmp_terms(a: LTerm, b: LTerm, exact: bool) -> Ordering {
  // Comparison might want to recurse, to avoid stack growth, do a switch here
  // and continue comparing. We grow `stack` instead of a CPU stack.
  let mut stack = Vec::<ContinueCompare>::new();
  let mut op = ContinueCompare::AnyType(a, b);
  loop {
    let eq_result = match op {
      ContinueCompare::AnyType(a1, b1) |
      ContinueCompare::Cons(a1, b1) => {
        cmp_terms_any_type(a1, b1, exact)
      },
    };
    match eq_result {
      EqResult::Concluded(result) if result == Ordering::Equal => {
        if stack.is_empty() {
          //println!("comparison {} {} concluded {:?}", a, b, result);
          return result
        } else {
          //println!("comparison {} {} got intermediate result {:?}", a, b, result);
          op = stack.pop().unwrap();
          continue
        } // stack not empty
      },
      EqResult::Concluded(result) => return result,
      // Nested terms may accidentally compare equal, to be able to return and
      // continue comparing upper level term, we store a `continue_op` on
      // `stack`.
      EqResult::CompareNested(a3, b3, continue_op) => {
        stack.push(continue_op);
        op = ContinueCompare::AnyType(a3, b3);
        continue
      },
    }
  }
}
pub fn cmp_terms ( a : LTerm , b : LTerm , exact : bool ) -> Ordering { // Comparison might want to recurse, to avoid stack growth, do a switch here // and continue comparing. We grow `stack` instead of a CPU stack. let mut stack = Vec :: < ContinueCompare > :: new ( ) ; let mut op = ContinueCompare :: AnyType ( a , b ) ; loop { let eq_result = match op { ContinueCompare :: AnyType ( a1 , b1 ) | ContinueCompare :: Cons ( a1 , b1 ) => { cmp_terms_any_type ( a1 , b1 , exact ) } , } ; match eq_result { EqResult :: Concluded ( result ) if result == Ordering :: Equal => { if stack . is_empty ( ) { //println!("comparison {} {} concluded {:?}", a, b, result); return result } else { //println!("comparison {} {} got intermediate result {:?}", a, b, result); op = stack . pop ( ) . unwrap ( ) ; continue } // stack not empty } , EqResult :: Concluded ( result ) => return result , // Nested terms may accidentally compare equal, to be able to return and // continue comparing upper level term, we store a `continue_op` on // `stack`. EqResult :: CompareNested ( a3 , b3 , continue_op ) => { stack . push ( continue_op ) ; op = ContinueCompare :: AnyType ( a3 , b3 ) ; continue } , } } }
Compare two terms for equality, fail if types are different even if
coercion is otherwise possible.
Compare two terms for equality fail if types are different even if coercion is otherwise possible .
a
LTerm
b
LTerm
exact
bool