From c31791ddda2845896c67b0c20a51a033ca0079a2 Mon Sep 17 00:00:00 2001 From: Emin Arslan Date: Thu, 30 Oct 2025 18:42:57 +0000 Subject: [PATCH] Add List Operations --- List-Operations.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 List-Operations.md diff --git a/List-Operations.md b/List-Operations.md new file mode 100644 index 0000000..7ce41fe --- /dev/null +++ b/List-Operations.md @@ -0,0 +1,18 @@ +# List utilities + +- (cons 1 (cons 2 ())) -> (1 2) + +cons produces a new cons cell (essentially a pair of two values). Cons cells (or pairs) form the basis of linked lists, +and therefore all source code. + +- (car '(1 2 3 4)) -> 1 + +car returns the first item of a cons cell. + +- (cdr '(1 2 3 4)) -> (2 3 4) + +cdr returns the second item of a cons cell. + +- (list 1 2 3 4) -> (1 2 3 4) + +list is a function takes any number of parameters, and produces a list containing only those elements in the order passed to it.