core: Add logxor.

* src/math.c (logxor): New function.
* tests/math.test ("logxor"): Test it.
This commit is contained in:
Jan Nieuwenhuizen 2018-05-16 22:30:08 +02:00
parent 7f0af1b46a
commit c4abd50a53
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273
2 changed files with 14 additions and 0 deletions

View file

@ -191,6 +191,19 @@ lognot (SCM x)
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
ash (SCM n, SCM count)
{

View file

@ -36,6 +36,7 @@ exit $?
(pass-if-equal "modulo" 2 (modulo 11 3))
(pass-if-equal "expt" 8 (expt 2 3))
(pass-if-equal "logior" 7 (logior 0 1 2 4))
(pass-if-equal "logxor" -2 (logxor 1 -1))
(pass-if-equal "ash"
8 (ash 1 3))
(pass-if-equal "ash -1"