summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Cerqueira <dan.git@lispclub.com>2026-02-26 12:15:10 +0000
committerDaniel Cerqueira <dan.git@lispclub.com>2026-02-26 12:15:10 +0000
commit73db4523540bd73b9717d13b58a24130de0234fa (patch)
treeb58aed056c058a59a322ce6bc334d367933f9197
parent95dcacea5a1eabfee54c3edbe11b844bf1e5a2ec (diff)
add singul functionHEADmain
-rw-r--r--README.md8
-rw-r--r--liblali.c2
2 files changed, 10 insertions, 0 deletions
diff --git a/README.md b/README.md
index 82e1f02..886e4c6 100644
--- a/README.md
+++ b/README.md
@@ -186,6 +186,14 @@ atom(s), otherwise `f`:
(consp t) ; f
(consp '(a b)) ; t
+`(singul x)` returns `t` if `x` is either an empty list `()`, or an atom,
+otherwise `f`:
+
+ (singul ()) ; t
+ (singul +1) ; t
+ (singul t) ; t
+ (singul '(a b)) ; f
+
`(zerop x)` returns `t` if `x` is the number zero, otherwise `f`:
(zerop +0) ; t
diff --git a/liblali.c b/liblali.c
index cadd9e1..af3f108 100644
--- a/liblali.c
+++ b/liblali.c
@@ -1664,6 +1664,8 @@ static char *stdlib = LISP(
(defun consp (x) (and (listp x) (algo x)))
+ (defun singul (x) (not (consp x)))
+
(defun differ (x y)
(fill ((and (consp x) (consp y)) (dif x y))
(f (or (differ (car x) (car y))