summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arith.c28
-rw-r--r--txr.116
2 files changed, 43 insertions, 1 deletions
diff --git a/arith.c b/arith.c
index 7700ea07..abf9f1be 100644
--- a/arith.c
+++ b/arith.c
@@ -2241,6 +2241,15 @@ val logand(val a, val b)
return zero;
switch (TYPE_PAIR(type(a), type(b))) {
+ case TYPE_PAIR(NUM, CHR):
+ case TYPE_PAIR(CHR, NUM):
+ if (a == b) {
+ return a;
+ } else {
+ cnum ac = c_num(a);
+ cnum bc = c_num(b);
+ return chr(ac & bc);
+ }
case TYPE_PAIR(NUM, NUM):
if (a == b) {
return a;
@@ -2282,6 +2291,15 @@ val logior(val a, val b)
return zero;
switch (TYPE_PAIR(type(a), type(b))) {
+ case TYPE_PAIR(NUM, CHR):
+ case TYPE_PAIR(CHR, NUM):
+ if (a == b) {
+ return a;
+ } else {
+ cnum ac = c_num(a);
+ cnum bc = c_num(b);
+ return chr(ac | bc);
+ }
case TYPE_PAIR(NUM, NUM):
if (a == b) {
return a;
@@ -2323,6 +2341,15 @@ val logxor(val a, val b)
return zero;
switch (TYPE_PAIR(type(a), type(b))) {
+ case TYPE_PAIR(NUM, CHR):
+ case TYPE_PAIR(CHR, NUM):
+ if (a == b) {
+ return a;
+ } else {
+ cnum ac = c_num(a);
+ cnum bc = c_num(b);
+ return chr(ac ^ bc);
+ }
case TYPE_PAIR(NUM, NUM):
if (a == b) {
return a;
@@ -2593,6 +2620,7 @@ val bit(val a, val bit)
switch (type(a)) {
case NUM:
+ case CHR:
{
cnum an = c_num(a);
if (bn < (SIZEOF_PTR * CHAR_BIT))
diff --git a/txr.1 b/txr.1
index 29195b97..a36c0f27 100644
--- a/txr.1
+++ b/txr.1
@@ -34865,6 +34865,20 @@ the value -1 (all bits 1). If
is called with no arguments it produces
zero. In the one-argument case, the functions just return their argument value.
+In the two-argument case, one of the operands may be a character, if the other
+operand is a fixnum integer. The character operand is taken to be an integer
+corresponding to the character value's Unicode code point value. The resulting
+value is regarded as a Unicode code point and converted to a character value
+accordingly.
+
+When three or more arguments are specified, the operation's semantics is
+that of a left-associative reduction through two-argument invocations,
+so that the three-argument case
+.code "(logand a b c)"
+is equivalent to the expression
+.codn "(logand (logand a b) c)" ,
+which features two two-argument cases..
+
.coNP Function @ logtest
.synb
.mets (logtest < int1 << int2 )
@@ -35008,7 +35022,7 @@ and
.desc
The
.code bit
-function tests whether the integer
+function tests whether the integer or character
.meta value
has a 1 in bit position
.metn bit .