From 80cb2f6b6085c10568d7857aa5ced393c01e651a Mon Sep 17 00:00:00 2001 From: Simon Brooke Date: Mon, 2 Jan 2017 14:06:32 +0000 Subject: [PATCH] Trial save to make sure I've got some wiki formatting right! --- core-functions.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 core-functions.md diff --git a/core-functions.md b/core-functions.md new file mode 100644 index 0000000..b69baf5 --- /dev/null +++ b/core-functions.md @@ -0,0 +1,41 @@ +# (atom arg) + +Public. Takes one argument. Returns TRUE if that argument is neither a CONS cell nor a STRG cell, else NIL. + +# (car arg) + +Public. Takes one argument. If that argument is a CONS cell and is readable by the current user, returns the value indicated by the first pointer of that cell, else NIL. + +# (cdr arg) + +Public. Takes one argument. If that argument is a CONS cell and is readable by the current user, returns the value indicated by the second pointer of that cell, else NIL. + +# (cond args...) + +Public. Takes an arbitrary number of arguments each of which are lists. The arguments are examined in turn until the first element of an argument evaluates to non-nil; then each of the remaining elements of that argument are evaluated in turn and the value of the last element returned. If no argument has a first element which evaluates to true, returns NIL. + +# (cons a d) + +Public. Takes two arguments, A, D. Returns a newly allocated cons cell whose first pointer points to A and whose second points to D. + +# (eq a b) + +Public. Takes two arguments, A, B. Returns TRUE if both are readable by the current user and are the same cons space object (i.e. pointer equality), else NIL. + +# (eval arg) + +Public. Takes one argument. +* if that argument is not readable by the current user, returns NIL. +* if that argument is a CONS, returns the result of + (apply (car arg) (cdr arg)) +* if that argument is an INTR, NIL, REAL, STRG, TRUE or VECP, returns the argument. +* if that argument is a READ or a WRIT, _probably_ returns the argument but I'm not yet certain. + +# (lambda args forms...) + +Public. Takes an arbitrary number of arguments. Considers the first argument ('args') as a set of formal parameters, and returns a function composed of the forms with those parameters bound. Where I say 'returns a function', this is in initial prototyping probably an interpreted function (i.e. a code tree implemented as an S-expression), but in a usable version will mean a VECP (see [[cons space#VECP]]) pointing to an EXEC (see [[vector space#EXEC]]) vector. + +# (quote arg) + +Public. Takes one argument. Returns that argument, protecting it from evaluation. +