mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-16 08:40:19 +02:00
Implement basic `equal?' implementation
* module/language/js-il/runtime.js (equal?): Remove primitive. Implement as builtin procedure. This version Only handles pairs.
This commit is contained in:
parent
024bd93b0d
commit
3f9bc2dbb0
1 changed files with 18 additions and 2 deletions
|
@ -496,8 +496,6 @@ scheme.primitives["eqv?"] = function(x, y) {
|
||||||
return coerce_bool(x === y);
|
return coerce_bool(x === y);
|
||||||
};
|
};
|
||||||
|
|
||||||
scheme.primitives["equal?"] = not_implemented_yet;
|
|
||||||
|
|
||||||
// Fluids
|
// Fluids
|
||||||
scheme.Fluid = function (x) {
|
scheme.Fluid = function (x) {
|
||||||
this.value = x;
|
this.value = x;
|
||||||
|
@ -761,6 +759,24 @@ def_guile0("append", function (self, cont, l1, l2) {
|
||||||
return cont(l);
|
return cont(l);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
function scm_equal(x,y) {
|
||||||
|
if (x instanceof scheme.Pair) {
|
||||||
|
if (y instanceof scheme.Pair) {
|
||||||
|
return (scm_equal(x.car,y.car) && scm_equal(x.cdr,y.cdr));
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
} else if (y instanceof scheme.Pair) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return (x === y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
def_guile0("equal?", function (self, cont, x, y) {
|
||||||
|
return cont(coerce_bool(scm_equal(x,y)));
|
||||||
|
});
|
||||||
|
|
||||||
def_guile0("memq", function (self, cont, val, args) {
|
def_guile0("memq", function (self, cont, val, args) {
|
||||||
return cont(scheme.FALSE);
|
return cont(scheme.FALSE);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue