core: Add logand, lognot.

* src/math.c (logand, lognot): New function.
This commit is contained in:
Jan Nieuwenhuizen 2017-08-27 12:53:01 +02:00
parent 989bfdbd25
commit 4175579d08

View file

@ -135,6 +135,19 @@ multiply (SCM x) ///((name . "*") (arity . n))
return MAKE_NUMBER (n);
}
SCM
logand (SCM x) ///((arity . n))
{
int n = 0;
while (x != cell_nil)
{
assert (TYPE (car (x)) == TNUMBER);
n &= VALUE (car (x));
x = cdr (x);
}
return MAKE_NUMBER (n);
}
SCM
logior (SCM x) ///((arity . n))
{
@ -148,6 +161,14 @@ logior (SCM x) ///((arity . n))
return MAKE_NUMBER (n);
}
SCM
lognot (SCM x)
{
assert (TYPE (x) == TNUMBER);
int n = ~VALUE (x);
return MAKE_NUMBER (n);
}
SCM
ash (SCM n, SCM count)
{