swissChili | e9fec8b | 2021-06-22 13:59:33 -0700 | [diff] [blame] | 1 | Lisp Standard Library |
| 2 | ===================== |
| 3 | |
| 4 | This provides documentation for every built-in function in the Lisp standard |
| 5 | library. It is not auto-generated, please update this documentation if you |
| 6 | change the API in any way. |
| 7 | |
| 8 | In general every user-facing API in the standard library should be documented |
| 9 | here. |
| 10 | |
| 11 | Built-in "functions" |
| 12 | -------------------- |
| 13 | |
| 14 | .. function:: (if condition true-condition [false-condition]) |
| 15 | |
| 16 | Evaluates ``condition``, if it is truthy (non-``nil``) ``true-condition`` is |
| 17 | evaluated. Otherwise ``false-condition`` is evaluated. If |
| 18 | ``false-condition`` is not provided, ``if`` will evaluate to ``nil``. |
| 19 | |
| 20 | .. function:: (let1 (variable binding) & body) |
| 21 | |
| 22 | Evaluates ``binding`` and binds it to ``variable``, then evaluates ``body``. |
| 23 | After ``body`` is evaluated ``variable`` is unbound. |
| 24 | |
| 25 | .. code-block:: lisp |
| 26 | |
| 27 | (let1 (greeting (greet "John")) |
| 28 | (do-something greeting) |
| 29 | (print greeting)) |
| 30 | ; greeting is no longer bound |
| 31 | |
| 32 | .. function:: (gc) |
| 33 | |
| 34 | Force the garbage collector (GC) to run. |
| 35 | |
| 36 | Functions |
| 37 | --------- |
| 38 | |
| 39 | .. function:: (car pair) |
| 40 | |
| 41 | Return the first item in ``pair``. |
| 42 | |
| 43 | .. function:: (cdr pair) |
| 44 | |
| 45 | Return the second (last) item in ``pair``. |
| 46 | |
| 47 | .. function:: (cons a b) |
| 48 | |
| 49 | Return a cons-pair containing ``a`` and ``b``. |
| 50 | |
| 51 | .. function:: (print val) |
| 52 | |
| 53 | Print out ``val`` to standard output. This will not be formatted as an |
| 54 | s-expression, but in a manner more similar to the internal representation. |