Bug fixes

This commit is contained in:
Justin Ethier 2016-07-07 23:39:49 -04:00
parent 6794da5159
commit 8e0e7309a2

View file

@ -880,13 +880,13 @@ object memqp(void *data, object x, list l)
*/ */
object equalp(object x, object y) object equalp(object x, object y)
{ {
object slow_lis = x, fast_lis; object slow_lis = x, fast_lis = NULL;
int second_cycle = 0; int second_cycle = 0;
// if (Cyc_is_pair(x) == boolean_t && if (Cyc_is_pair(x) == boolean_t &&
// Cyc_is_pair(cdr(x)) == boolean_t){ Cyc_is_pair(cdr(x)) == boolean_t){
// fast_lis = cdr(x); fast_lis = cdr(x);
// } }
for (;; x = cdr(x), y = cdr(y)) { for (;; x = cdr(x), y = cdr(y)) {
if (equal(x, y)) if (equal(x, y))
@ -900,30 +900,31 @@ object equalp(object x, object y)
if (boolean_f == equalp(car(x), car(y))) if (boolean_f == equalp(car(x), car(y)))
return boolean_f; return boolean_f;
// // If there is no cycle, keep checking equality // If there is no cycle, keep checking equality
// if (fast_lis == NULL || if (fast_lis == NULL ||
// Cyc_is_pair(fast_lis) == boolean_f || Cyc_is_pair(fast_lis) == boolean_f ||
// cdr(fast_lis) == NULL || cdr(fast_lis) == NULL ||
// Cyc_is_pair(cdr(fast_lis)) == boolean_f || Cyc_is_pair(cdr(fast_lis)) == boolean_f ||
// cddr(fast_lis) == NULL){ cddr(fast_lis) == NULL){
// continue; continue;
// } }
//
// // If there is a cycle, handle it // If there is a cycle, handle it
// if (slow_lis == fast_lis) { if (slow_lis == fast_lis) {
// // if this is y, both lists have cycles and are equal, return #t // if this is y, both lists have cycles and are equal, return #t
// if (second_cycle) if (second_cycle)
// return boolean_t; return boolean_t;
// // if this is x, keep going and check for a cycle in y // if this is x, keep going and check for a cycle in y
// second_cycle = 1; second_cycle = 1;
// slow_lis = y; slow_lis = y;
// if (Cyc_is_pair(y) == boolean_t) { fast_lis = NULL;
// fast_lis = cdr(y); if (Cyc_is_pair(y) == boolean_t) {
// } fast_lis = cdr(y);
// continue; }
// } continue;
// slow_lis = cdr(slow_lis); }
// fast_lis = cddr(fast_lis); slow_lis = cdr(slow_lis);
fast_lis = cddr(fast_lis);
} }
} }