Added logical operators and, not and or. Closes #3

This commit is contained in:
Simon Brooke 2026-02-24 01:45:51 +00:00
parent 8df304bc60
commit 62ebaf9819
13 changed files with 422 additions and 132 deletions

4
lisp/documentation.lisp Normal file
View file

@ -0,0 +1,4 @@
(set! documentation (lambda (name)
(:documentation (meta name))))
(set! doc documentation)

3
lisp/greaterp.lisp Normal file
View file

@ -0,0 +1,3 @@
(set! > (lambda (a b)
)

7
lisp/member.lisp Normal file
View file

@ -0,0 +1,7 @@
(set! member (lambda
(item collection)
"Return `t` if this `item` is a member of this `collection`, else `nil`."
(cond
((nil? collection) nil)
((= item (car collection)) t)
(t (member item (cdr collection))))))

6
lisp/nth.lisp Normal file
View file

@ -0,0 +1,6 @@
(set! nth (lambda (n l)
"Return the `n`th member of this list `l`, or `nil` if none."
(cond ((= nil l) nil)
((= n 1) (car l))
(t (nth (- n 1) (cdr l))))))

View file

@ -1,17 +1,17 @@
(set! cons? (lambda (o) "True if o is a cons cell." (= (type o) "CONS") ) )
(set! exception? (lambda (o) "True if o is an exception." (= (type o) "EXEP")))
(set! free? (lambda (o) "Trus if o is a free cell - this should be impossible!" (= (type o) "FREE")))
(set! function? (lambda (o) "True if o is a compiled function." (= (type o) "EXEP")))
(set! integer? (lambda (o) "True if o is an integer." (= (type o) "INTR")))
(set! lambda? (lambda (o) "True if o is an interpreted (source) function." (= (type o) "LMDA")))
(set! nil? (lambda (o) "True if o is the canonical nil value." (= (type o) "NIL ")))
(set! nlambda? (lambda (o) "True if o is an interpreted (source) special form." (= (type o) "NLMD")))
(set! rational? (lambda (o) "True if o is an rational number." (= (type o) "RTIO")))
(set! read? (lambda (o) "True if o is a read stream." (= (type o) "READ") ) )
(set! real? (lambda (o) "True if o is an real number." (= (type o) "REAL")))
(set! special? (lambda (o) "True if o is a compiled special form." (= (type o) "SPFM") ) )
(set! string? (lambda (o) "True if o is a string." (= (type o) "STRG") ) )
(set! symbol? (lambda (o) "True if o is a symbol." (= (type o) "SYMB") ) )
(set! true? (lambda (o) "True if o is the canonical true value." (= (type o) "TRUE") ) )
(set! write? (lambda (o) "True if o is a write stream." (= (type o) "WRIT") ) )
(set! cons? (lambda (o) "True if `o` is a cons cell." (= (type o) "CONS") ) )
(set! exception? (lambda (o) "True if `o` is an exception." (= (type o) "EXEP")))
(set! free? (lambda (o) "Trus if `o` is a free cell - this should be impossible!" (= (type o) "FREE")))
(set! function? (lambda (o) "True if `o` is a compiled function." (= (type o) "EXEP")))
(set! integer? (lambda (o) "True if `o` is an integer." (= (type o) "INTR")))
(set! lambda? (lambda (o) "True if `o` is an interpreted (source) function." (= (type o) "LMDA")))
(set! nil? (lambda (o) "True if `o` is the canonical nil value." (= (type o) "NIL ")))
(set! nlambda? (lambda (o) "True if `o` is an interpreted (source) special form." (= (type o) "NLMD")))
(set! rational? (lambda (o) "True if `o` is an rational number." (= (type o) "RTIO")))
(set! read? (lambda (o) "True if `o` is a read stream." (= (type o) "READ") ) )
(set! real? (lambda (o) "True if `o` is an real number." (= (type o) "REAL")))
(set! special? (lambda (o) "True if `o` is a compiled special form." (= (type o) "SPFM") ) )
(set! string? (lambda (o) "True if `o` is a string." (= (type o) "STRG") ) )
(set! symbol? (lambda (o) "True if `o` is a symbol." (= (type o) "SYMB") ) )
(set! true? (lambda (o) "True if `o` is the canonical true value." (= (type o) "TRUE") ) )
(set! write? (lambda (o) "True if `o` is a write stream." (= (type o) "WRIT") ) )