Trial save to make sure I've got some wiki formatting right!

Simon Brooke 2017-01-02 14:06:32 +00:00
parent 8ef727da90
commit 80cb2f6b60

41
core-functions.md Normal file

@ -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.