core: Add logxor.
* src/math.c (logxor): New function. * tests/math.test ("logxor"): Test it.
This commit is contained in:
parent
7f0af1b46a
commit
c4abd50a53
13
src/math.c
13
src/math.c
|
@ -191,6 +191,19 @@ lognot (SCM x)
|
||||||
return MAKE_NUMBER (n);
|
return MAKE_NUMBER (n);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SCM
|
||||||
|
logxor (SCM x) ///((arity . n))
|
||||||
|
{
|
||||||
|
int n = 0;
|
||||||
|
while (x != cell_nil)
|
||||||
|
{
|
||||||
|
assert_number ("logxor", CAR (x));
|
||||||
|
n ^= VALUE (car (x));
|
||||||
|
x = cdr (x);
|
||||||
|
}
|
||||||
|
return MAKE_NUMBER (n);
|
||||||
|
}
|
||||||
|
|
||||||
SCM
|
SCM
|
||||||
ash (SCM n, SCM count)
|
ash (SCM n, SCM count)
|
||||||
{
|
{
|
||||||
|
|
|
@ -36,6 +36,7 @@ exit $?
|
||||||
(pass-if-equal "modulo" 2 (modulo 11 3))
|
(pass-if-equal "modulo" 2 (modulo 11 3))
|
||||||
(pass-if-equal "expt" 8 (expt 2 3))
|
(pass-if-equal "expt" 8 (expt 2 3))
|
||||||
(pass-if-equal "logior" 7 (logior 0 1 2 4))
|
(pass-if-equal "logior" 7 (logior 0 1 2 4))
|
||||||
|
(pass-if-equal "logxor" -2 (logxor 1 -1))
|
||||||
(pass-if-equal "ash"
|
(pass-if-equal "ash"
|
||||||
8 (ash 1 3))
|
8 (ash 1 3))
|
||||||
(pass-if-equal "ash -1"
|
(pass-if-equal "ash -1"
|
||||||
|
|
Loading…
Reference in a new issue