articles/lisp.md: update

This commit is contained in:
tocariimaa 2025-02-15 13:04:13 -03:00
parent 677467e04c
commit 44ef71c658

View file

@ -18,10 +18,10 @@ a Lisp could be built in terms of lambdas. For example, using Church encoding th
(define (car p) (p (lambda (x y) x)))
(define (cdr p) (p (lambda (x y) y)))
(cdr (cons 'A 'B)) ; B
(car (cons 'A 'B)) ; A
(car (cdr (cons 'A (cons 'B 'C)))) ; B
(cdr (cdr (cons 'A (cons 'B 'C)))) ; C
(cdr (cons 'A 'B)) ; ==> B
(car (cons 'A 'B)) ; ==> A
(car (cdr (cons 'A (cons 'B 'C)))) ; ==> B
(cdr (cdr (cons 'A (cons 'B 'C)))) ; ==> C
```
A PDF of the original Lisp 1.5 manual can be found here: <https://www.lispmachine.net/books/LISP_1.5_Programmers_Manual.pdf>. Head to page 13 for
@ -43,9 +43,9 @@ Here's cons cell:
To create a cell, the builtin function `cons` is used:
```lisp
(cons 1 2) ; 1 and 2 are the car and cdr respectively
(car (cons 1 2)) ; ==> 1
(cdr (cons 1 2)) ; ==> 2
(cons 1 2) ; 1 and 2 are the car and cdr respectively
(car (cons 1 2)) ; ==> 1
(cdr (cons 1 2)) ; ==> 2
;; Also some Lisps accept the "dotted pair" notation as a shorthand:
(1 . 2)
```
@ -100,5 +100,5 @@ you're seeing the source encoded in a tree, directly by using S-Expressions. But
under a Lisp skin.
- ...
## Examples
TODO
## See Also
- [Forth](forth.md)