summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Cerqueira <dan.git@lispclub.com>2026-08-20 22:24:46 +0100
committerDaniel Cerqueira <dan.git@lispclub.com>2026-08-20 23:05:56 +0100
commit8ff3147e497c12bc2c80d0a2b4311afff3920d05 (patch)
treef82803b7b79c9e3d88dacbba5070f6982c2bc43f
parentc9d6fd4188361a7066a0b52c74c3bc3b81f459bc (diff)
update documentation
-rw-r--r--README.md24
1 files changed, 15 insertions, 9 deletions
diff --git a/README.md b/README.md
index 63bd75a..cf617d0 100644
--- a/README.md
+++ b/README.md
@@ -126,7 +126,9 @@ which is `y`:
`(car x)`, `(cdr x)` return the `car` and `cdr` of a list respectively:
(car '(a b c)) ; a
+ (car ()) ; ()
(cdr '(a b c)) ; (b c)
+ (cdr ()) ; ()
### Predicates
@@ -206,6 +208,10 @@ otherwise `f`:
`(not x)` returns `t` if `x` is `f`, return `n` if `x` is `n`, otherwise returns
`f`.
+ (not n) ; n
+ (not t) ; f
+ (not f) ; t
+
`(and ...)` evaluates its arguments one at a time from left to right. As soon as
any argument evaluates to `f`, `and` returns `f` without evaluating the remaining
arguments. Otherwise, it returns the value produced by evaluating its last
@@ -225,9 +231,9 @@ the remaining arguments. Otherwise, it returns `f`:
### Conditionals
-`(cond ...)` takes zero or more clauses, each of the form `(test [expr...])`.
+`(cond ...)` takes no or some clause(s), each of the form `(test [expr...])`.
`cond` returns the result of evaluating `expr...` of the first clause for which
-`test` does not evaluate to `f` without evaluating the remaining clauses. If a
+`test` does not evaluate to `f`, without evaluating the remaining clauses. If a
clause does not supply `expr...`, the result of evaluating `test` is returned
instead. If every `test` evaluates to `f`, or no clauses are given, `cond` returns
`n`:
@@ -241,7 +247,7 @@ instead. If every `test` evaluates to `f`, or no clauses are given, `cond` retur
('World)) ; Hello
`(fill ...)` is similar to `cond`. But `fill` differs in its evaluation of `test`.
-When `test` does evaluate to `f` returns the result of evaluating `expr...`
+When `test` does evaluate to `f` returns the result of evaluating `expr...`,
without evaluating the remaining clauses:
(fill) ; n
@@ -254,7 +260,7 @@ without evaluating the remaining clauses:
### Grouping functions
-`(prog ...)` takes zero or more expressions, and evaluates each expression, one
+`(prog ...)` takes no or some expression(s), and evaluates each expression, one
after the other. Returns the evaluation of the last expression. Returns `n`, if no
expression is given:
@@ -350,7 +356,7 @@ Macros are different from functions in that they do not evaluate their arguments
when called. Instead, we can think of them as taking expressions as input and
returning a new expression as output.
-Imagine we want to implement `(when test expr...)`:
+Imagine we want to implement `(when test expr...)` below:
(set 'x '(+1 +2 +3)) ; (+1 +2 +3)
(when (consp x)
@@ -370,20 +376,20 @@ However, we can implement `when` as a macro that wraps `expr...` in a call to
`cond`:
(defmacro when (test . expr)
- (list cond (list test (cons 'prog expr))))
+ (list 'cond (list test (cons 'prog expr))))
`(when (consp x) (car x))` would then produce the expression
`(cond ((consp x) (prog (car x))))` which yields the expected behaviour.
### Input operation
-`(read)` takes zero arguments, and reads an expression from standard input:
+`(read)` takes no arguments, and reads an expression from standard input:
(set 'a (read)) ; type (Hello World!) followed by an enter
a ; (Hello World!)
`(readl)` is similar to `read`. But `readl` differs because it reads an expression
-as as a list, without needing to type the parenthesis at the beginning and at the
+as a list, without needing to type the parenthesis at the beginning and at the
end.
(set 'a (readl)) ; type (Hello World!) followed by an enter
@@ -414,7 +420,7 @@ end.
(print '(Hello World!)) ; prints (Hello World!) followed by a space
-`(princ x)` is similar to `print`. But `princ` differs in its handling of lists
+`(princ x)` is similar to `print`. But `princ` differs in its handling of lists,
outputting them without the initial/ending parenthesis:
(princ '(Hello World!)) ; prints Hello World! followed by a space