summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2025-05-16 20:58:40 -0700
committerKaz Kylheku <kaz@kylheku.com>2025-05-16 20:58:40 -0700
commit991dbd3717944ee0c6de1490a0b2305d4a120b41 (patch)
tree337ae4711d975a871766f04bc06c91279cd7a35e
parent559fd8d9466bef550d6f4274deeddc3b27dfc22a (diff)
downloadtxr-991dbd3717944ee0c6de1490a0b2305d4a120b41.tar.gz
txr-991dbd3717944ee0c6de1490a0b2305d4a120b41.tar.bz2
txr-991dbd3717944ee0c6de1490a0b2305d4a120b41.zip
infix: add missing ~ complement operator.
* stdlib/infix.tl (toplevel): New ~ operator, prefix at level 35, tied to lognot function. * tests/012/infix.tl: New tests. * txr.1: Documented.
-rw-r--r--stdlib/infix.tl1
-rw-r--r--tests/012/infix.tl4
-rw-r--r--txr.15
3 files changed, 8 insertions, 2 deletions
diff --git a/stdlib/infix.tl b/stdlib/infix.tl
index 1f544006..66bd9037 100644
--- a/stdlib/infix.tl
+++ b/stdlib/infix.tl
@@ -104,6 +104,7 @@
(new (ifx-oper 35 '-) arity :prefix assoc :right)
(new (ifx-oper 35 '+) arity :prefix assoc :right)
+(new (ifx-oper 35 '~) arity :prefix assoc :right lispsym 'lognot)
(new (ifx-oper 40 '*))
(new (ifx-oper 40 '/))
diff --git a/tests/012/infix.tl b/tests/012/infix.tl
index d3e1db54..a9d71ecc 100644
--- a/tests/012/infix.tl
+++ b/tests/012/infix.tl
@@ -196,3 +196,7 @@
(a + b + c) (+ a b c)
(a + b + c + d) (+ a b c d)
(a * b * c + d * e + e * f * g) (+ (* a b c) (* d e) (* e f g)))
+
+(mtest-ifx
+ (~ a) (lognot a)
+ (~ a | ~ b) (logior (lognot a) (lognot b)))
diff --git a/txr.1 b/txr.1
index e5bb67aa..7d832078 100644
--- a/txr.1
+++ b/txr.1
@@ -55486,7 +55486,7 @@ mathfn \f[4]=\f[],prefix,0,right
\f[4]&\f[],infix,7,left
\f[4]<< >>\f[],infix,8,left
\f[4]+ -\f[],infix,9,left
-\f[4]+ -\f[],prefix,10,right
+\f[4]+ - ~\f[],prefix,10,right
\f[4]* / %\f[],infix,11,left
\f[4]**\f[],infix,12,right
\f[4]++ --\f[],prefix,13,right
@@ -55604,13 +55604,14 @@ that only a single evaluation takes place:
a || b -> (or a b)
a && b -> (and a b)
- ! a -> (not a)
+ ! a -> (not a)
a != b -> (/= a b)
a | b -> (logior a b)
a ~ b -> (logxor a b)
a & b -> (logand a b)
+ ~ b -> (lognot b)
a % b -> (mod a b)
a // b -> (floor a b)