home *** CD-ROM | disk | FTP | other *** search
/ GEMini Atari / GEMini_Atari_CD-ROM_Walnut_Creek_December_1993.iso / files / portfoli / xlisp / xlisp.doc < prev    next >
Encoding:
Text File  |  1991-12-31  |  79.1 KB  |  2,766 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6.  
  7.                          XLISP: An Object-oriented Lisp
  8.  
  9.                                   Version 2.0
  10.  
  11.                                 February 6, 1988
  12.  
  13.  
  14.                                        by
  15.                                David Michael Betz
  16.                                 127 Taylor Road
  17.                              Peterborough, NH 03458
  18.  
  19.                              (603) 924-6936 (home)
  20.  
  21.                    Copyright (c) 1988, by David Michael Betz
  22.                               All Rights Reserved
  23.            Permission is granted for unrestricted non-commercial use
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46.  
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70.         XLISP                  TABLE OF CONTENTS                  Page 2
  71.  
  72.  
  73.                                Table of Contents
  74.  
  75.  
  76.                 TABLE OF CONTENTS                        2
  77.  
  78.                 INTRODUCTION                             4
  79.  
  80.                 A NOTE FROM THE AUTHOR                   5
  81.  
  82.                 XLISP COMMAND LOOP                       6
  83.  
  84.                 BREAK COMMAND LOOP                       7
  85.  
  86.                 DATA TYPES                               8
  87.  
  88.                 THE EVALUATOR                            9
  89.  
  90.                 LEXICAL CONVENTIONS                     10
  91.  
  92.                 READTABLES                              11
  93.  
  94.                 LAMBDA LISTS                            12
  95.  
  96.                 OBJECTS                                 14
  97.  
  98.                 SYMBOLS                                 17
  99.  
  100.                 EVALUATION FUNCTIONS                    18
  101.  
  102.                 SYMBOL FUNCTIONS                        19
  103.  
  104.                 PROPERTY LIST FUNCTIONS                 21
  105.  
  106.                 ARRAY FUNCTIONS                         22
  107.  
  108.                 LIST FUNCTIONS                          23
  109.  
  110.                 DESTRUCTIVE LIST FUNCTIONS              26
  111.  
  112.                 PREDICATE FUNCTIONS                     27
  113.  
  114.                 CONTROL CONSTRUCTS                      29
  115.  
  116.                 LOOPING CONSTRUCTS                      31
  117.  
  118.                 THE PROGRAM FEATURE                     32
  119.  
  120.                 DEBUGGING AND ERROR HANDLING            33
  121.  
  122.                 ARITHMETIC FUNCTIONS                    34
  123.  
  124.                 BITWISE LOGICAL FUNCTIONS               36
  125.  
  126.                 STRING FUNCTIONS                        37
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.         XLISP                  TABLE OF CONTENTS                  Page 3
  137.  
  138.  
  139.                 CHARACTER FUNCTIONS                     39
  140.  
  141.                 INPUT/OUTPUT FUNCTIONS                  41
  142.  
  143.                 THE FORMAT FUNCTION                     42
  144.  
  145.                 FILE I/O FUNCTIONS                      43
  146.  
  147.                 STRING STREAM FUNCTIONS                 44
  148.  
  149.                 SYSTEM FUNCTIONS                        45
  150.  
  151.                 EXAMPLES                                47
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.         XLISP                     INTRODUCTION                    Page 4
  203.  
  204.  
  205.         INTRODUCTION
  206.  
  207.         XLISP is an experimental programming language combining some of
  208.         the features of Common Lisp with an object-oriented extension
  209.         capability.  It was implemented to allow experimentation with
  210.         object-oriented programming on small computers.
  211.  
  212.         There are currently implementations of XLISP running on the IBM-
  213.         PC and clones under MS-DOS, on the Macintosh, the Atari-ST and
  214.         the Amiga.  It is completely written in the programming language
  215.         'C' and is easily extended with user written built-in functions
  216.         and classes.  It is available in source form to non-commercial
  217.         users.
  218.  
  219.         Many Common Lisp functions are built into XLISP.  In addition,
  220.         XLISP defines the objects 'Object' and 'Class' as primitives.
  221.         'Object' is the only class that has no superclass and hence is
  222.         the root of the class heirarchy tree.  'Class' is the class p✓≡ננננננננÇ⇨é ⇨נÄ⇧üנî⇧Ä⇦⇦✓⇦OÄ⇦êOéä⇧Äî✓⇦Oבé⇧נé⇦OüâêOÇüéOÇ Çê ⇧נüâÄ⇧נé⇦pננננננננÄנéä⇧Äî✓OÇ✓נé⇧ä✓⇧êא@≡≡ננננננננüâé⇦OëÇ ✓üנé⇦OÄOîäé✓✓נëê⇦ ⇦é◆üéנÇ✓נâæÆ⇦◆ijננÆ⇧נÄ⇦⇦✓⇦Oä✓pננננננננÇÇ⇧ê    ê✓OÇ✓נæÆ⇦◆er than a
  223.         number, the entire trace back stack is printed.
  224.  
  225.         XLISP then enters a read/eval/print loop to allow the user to
  226.         examine the state of the interpreter in the context of the
  227.         error.  This loop differs from the normal top-level
  228.         read/eval/print loop in that if the user invokes the function
  229.         'continue', XLISP will continue from a correctable error.  If
  230.         the user invokes the function 'clean-up', XLISP will abort the
  231.         break loop and return to the top level or the next lower
  232.         numbered break loop.  When in a break loop, XLISP prefixes the
  233.         break level to the normal prompt.
  234.  
  235.         If the symbol '*breakenable*' is nil, XLISP looks for a
  236.         surrounding errset function.  If one is found, XLISP examines
  237.         the value of the print flag.  If this flag is true, the error
  238.         message is printed.  In any case, XLISP causes the errset
  239.         function call to return nil.
  240.  
  241.         If there is no surrounding errset function, XLISP prints the
  242.         error message and returns to the top level.
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.         XLISP                      DATA TYPES                     Page 8
  275.  
  276.  
  277.         DATA TYPES
  278.  
  279.         There are several different data types available to XLISP
  280.         programmers.
  281.  
  282.             o lists
  283.             o symbols
  284.             o strings
  285.             o integers
  286.             o characters
  287.             o floats
  288.             o objects
  289.             o arrays
  290.             o streams
  291.             o subrs (built-in functions)
  292.             o fsubrs (special forms)
  293.             o closures (user defined functions)
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.         XLISP                    THE EVALUATOR                    Page 9
  341.  
  342.  
  343.         THE EVALUATOR
  344.  
  345.         The process of evaluation in XLISP:
  346.  
  347.         Strings, integers, characters, floats, objects, arrays, streams,
  348.         subrs, fsubrs and closures evaluate to themselves.
  349.  
  350.         Symbols act as variables and are evaluated by retrieving the
  351.         value associated with their current binding.
  352.  
  353.         Lists are evaluated by examining the first element of the list
  354.         and then taking one of the following actions:
  355.  
  356.             If it is a symbol, the functional binding of the symbol is
  357.             retrieved.
  358.  
  359.             If it is a lambda expression, a closure is constructed for
  360.             the function described by the lambda expression.
  361.  
  362.             If it is a subr, fsubr or closure, it stands for itself.
  363.  
  364.             Any other value is an error.
  365.  
  366.         Then, the value produced by the previous step is examined:
  367.  
  368.             If it is a subr or closure, the remaining list elements are
  369.             evaluated and the subr or closure is called with these
  370.             evaluated expressions as arguments.
  371.  
  372.             If it is an fsubr, the fsubr is called using the remaining
  373.             list elements as arguments (unevaluated).
  374.  
  375.             If it is a macro, the macro is expanded using the remaining
  376.             list elements as arguments (unevaluated).  The macro
  377.             expansion is then evaluated in place of the original macro
  378.             call.
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.         XLISP                 LEXICAL CONVENTIONS                Page 10
  407.  
  408.  
  409.         LEXICAL CONVENTIONS
  410.  
  411.         The following conventions must be followed when entering XLISP
  412.         programs:
  413.  
  414.         Comments in XLISP code begin with a semi-colon character and
  415.         continue to the end of the line.
  416.  
  417.         Symbol names in XLISP can consist of any sequence of non-blank
  418.         printable characters except the following:
  419.  
  420.                 ( ) ' ` , " ;
  421.  
  422.         Uppercase and lowercase characters are not distinguished within
  423.         symbol names.  All lowercase characters are mapped to uppercase
  424.         on input.
  425.  
  426.         Integer literals consist of a sequence of digits optionally
  427.         beginning with a '+' or '-'.  The range of values an integer can
  428.         represent is limited by the size of a C 'long' on the machine on
  429.         which XLISP is running.
  430.  
  431.         Floating point literals consist of a sequence of digits
  432.         optionally beginning with a '+' or '-' and including an embedded
  433.         decimal point.  The range of values a floating point number can
  434.         represent is limited by the size of a C 'float' ('double' on
  435.         machines with 32 bit addresses) on the machine on which XLISP is
  436.         running.
  437.  
  438.         Literal strings are sequences of characters surrounded by double
  439.         quotes.  Within quoted strings the '\' character is used to
  440.         allow non-printable characters to be included.  The codes
  441.         recognized are:
  442.  
  443.                 \\        means the character '\'
  444.                 \n       means newline
  445.                 \t       means tab
  446.                 \r       means return
  447.                 \f       means form feed
  448.                 \nnn     means the character whose octal code is nnn
  449.  
  450.  
  451.  
  452.  
  453.  
  454.  
  455.  
  456.  
  457.  
  458.  
  459.  
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466.  
  467.  
  468.  
  469.  
  470.  
  471.  
  472.         XLISP                      READTABLES                    Page 11
  473.  
  474.  
  475.         READTABLES
  476.  
  477.         The behaviour of the reader is controlled by a data structure
  478.         called a "readtable".  The reader uses the symbol *READTABLE* to
  479.         locate the current readtable.  This table controls the
  480.         interpretation of input characters.  It is an array with 128
  481.         entries, one for each of the ASCII character codes.  Each entry
  482.         contains one of the following things:
  483.  
  484.                 NIL             Indicating an invalid character
  485.                 :CONSTITUENT    Indicating a symbol constituent
  486.                 :WHITE-SPACE    Indicating a whitespace character
  487.                 (:TMACRO . fun) Terminating readmacro
  488.                 (:NMACRO . fun) Non-terminating readmacro
  489.                 :SESCAPE        Single esπץ⓪ƒ⑧◆    ⑧⇨⓪    ƒçÉ⇨Éä⃃ƒƒƒƒƒƒƒƒƒƒƒƒƒƒü 0✓8<0ƒƒƒƒƒƒƒƒ ⇨⇨⇦⇨⓪ƒ⓪✓⑧⓪ƒ⑧◆    ⑧⇨⓪    ƒçÉ⇨Éäβ⃃ƒƒƒƒƒƒ$⇧ƒ⇨◆⓪ƒ⑧✓⓪ƒ①ƒü⇨ <8     ƒ⇧③ƒü! <8     âƒ⇨◆⓪ƒÖ①⇧Öƒ⑧⇧⓪⇧⇨ƒ⇦✓ƒ⃃ƒƒƒƒƒƒ①⇧⑧⇨⇦⇧üƒƒ⇨◆⇦✓ƒ⑧⇧ƒ⓪⇦⇨◆⓪    ƒ⑨⓪ƒƒ⑨⇦⇨⇨Ç⇦⇧ƒ    ⓪③⑧    ƒ①⇧⑧⇨⇦⇧ƒ    ƒ⃃ƒƒƒƒƒƒ⇨⑨③ƒ⓪◆    ⓪✓✓⇦⇧üƒƒ⇨◆⓪ƒ①⇧⑧⇨⇦⇧ƒ✓◆⇨③ƒ⇨⓪ƒ⇨ƒ    ⇩⓪⇨⓪    ✓ü⃃ƒƒƒƒƒƒ⇨◆⓪ƒ①⇦    ✓⇨ƒ⇦✓ƒ⇨◆⓪ƒ⇦⇧⇨ƒ✓⇨    ⓪ƒ⇧③ƒ⇨◆⓪ƒ✓⓪⑧⇧③ƒ⇦✓ƒ⇨◆⓪ƒ⑧◆    ⑧⇨⓪    βƒƒƒƒƒƒƒƒ⇩a 'supplied-p' variable that can be used to
  490.         determine if a call provided a value for the argument or if the
  491.         initialization expression was used.  If specified, the supplied-
  492.         p variable will be bound to T if a value was specified in the
  493.         call and NIL if the default value was used.
  494.  
  495.         The &optional arguments are followed by the &rest argument.  The
  496.         &rest argument gets bound to the remainder of the argument list
  497.         after the required and &optional arguments have been removed.
  498.  
  499.         The &rest argument is followed by the &key arguments.  When a
  500.         keyword argument is passed to a function, a pair of values
  501.         appears in the argument list.  The first expression in the pair
  502.         should evaluate to a keyword symbol (a symbol that begins with a
  503.         ':').  The value of the second expression is the value of the
  504.         keyword argument.  Like &optional arguments, &key arguments can
  505.         have initialization expressions and supplied-p variables.  In
  506.         addition, it is possible to specify the keyword to be used in a
  507.         function call.  If no keyword is specified, the keyword obtained
  508.         by adding a ':' to the beginning of the keyword argument symbol
  509.         is used.  In other words, if the keyword argument symbol is
  510.         'foo', the keyword will be ':foo'.
  511.  
  512.         The &key arguments are followed by the &aux variables.  These
  513.         are local variables that are bound during the evaluation of the
  514.         function body.  It is possible to have initialization
  515.         expressions for the &aux variables.
  516.  
  517.  
  518.  
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532.  
  533.  
  534.  
  535.  
  536.         XLISP                     LAMBDA LISTS                   Page 13
  537.  
  538.  
  539.         Here is the complete syntax for lambda lists:
  540.  
  541.                 (<rarg>...
  542.                  [&optional [<oarg> | (<oarg> [<init> [<svar>]])]...]
  543.                  [&rest <rarg>]
  544.                  [&key
  545.                    [<karg> | ([<karg> | (<key> <karg>)] [<init> [<svar>]])]...
  546.                    &allow-other-keys]
  547.                  [&aux
  548.                    [<aux> | (<aux> [<init>])]...])
  549.  
  550.             where:
  551.  
  552.                 <rarg>  is a required argument symbol
  553.                 <oarg>  is an &optional argument symbol
  554.                 <rarg>  is the &rest argument symbol
  555.                 <karg>  is a &key argument symbol
  556.                 <key>   is a keyword symbol
  557.                 <aux>   is an auxiliary variable symbol
  558.                 <init>  is an initialization expression
  559.                 <svar>  is a supplied-p variable symbol
  560.  
  561.  
  562.  
  563.  
  564.  
  565.  
  566.  
  567.  
  568.  
  569.  
  570.  
  571.  
  572.  
  573.  
  574.  
  575.  
  576.  
  577.  
  578.  
  579.  
  580.  
  581.  
  582.  
  583.  
  584.  
  585.  
  586.  
  587.  
  588.  
  589.  
  590.  
  591.  
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598.  
  599.  
  600.  
  601.  
  602.         XLISP                       OBJECTS                      Page 14
  603.  
  604.  
  605.         OBJECTS
  606.  
  607.         Definitions:
  608.  
  609.             o selector - a symbol used to select an appropriate method
  610.             o message - a selector and a list of actual arguments
  611.             o method - the code that implements a message
  612.  
  613.         Since XLISP was created to provide a simple basis for
  614.         experimenting with object-oriented programming, one of the
  615.         primitive data types included is 'object'.  In XLISP, an object
  616.         consists of a data structure containing a pointer to the
  617.         object's class as well as an array containing the values of the
  618.         object's instance variables.
  619.  
  620.         Officially, there is no way to see inside an object (look at the
  621.         values of its instance variables).  The only way to communicate
  622.         with an object is by sending it a message.
  623.  
  624.         You can send a message to an object using the 'send' function.
  625.         This function takes the object as its first argument, the
  626.         message selector as its second argument (which must be a symbol)
  627.         and the message arguments as its remaining arguments.
  628.  
  629.         The 'send' function determines the class of the receiving object
  630.         and attempts to find a method corresponding to the message
  631.         selector in the set of messages defined for that class.  If the
  632.         message is not found in the object's class and the class has a
  633.         super-class, the search continues by looking at the messages
  634.         defined for the super-class.  This process continues from one
  635.         super-class to the next until a method for the message is found.
  636.         If no method is found, an error occurs.
  637.  
  638.         A message can also be sent from the body of a method by using
  639.         the current object, but the method lookup starts with the
  640.         object's superclass rather than its class.  This allows a
  641.         subclass to invoke a standard method in its parent class even
  642.         though it overrides that method with its own specialized
  643.         version.
  644.  
  645.         When a method is found, the evaluator binds the receiving object
  646.         to the symbol 'self' and evaluates the method using the
  647.         remaining elements of the original list as arguments to the
  648.         method.  These arguments are always evaluated prior to being
  649.         bound to their corresponding formal arguments.  The result of
  650.         evaluating the method becomes the result of the expression.
  651.  
  652.  
  653.  
  654.  
  655.  
  656.  
  657.  
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664.  
  665.  
  666.  
  667.  
  668.         XLISP                       OBJECTS                      Page 15
  669.  
  670.  
  671.         THE 'Object' CLASS
  672.  
  673.         Classes:
  674.  
  675.         Object  THE TOP OF THE CLASS HEIRARCHY
  676.  
  677.             Messages:
  678.  
  679.                 :show  SHOW AN OBJECT'S INSTANCE VARIABLES
  680.                     returns     the object
  681.  
  682.                 :class  RETURN THE CLASS OF AN OBJECT
  683.                     returns     the class of the object
  684.  
  685.                 :isnew  THE DEFAULT OBJECT INITIALIZATION ROUTINE
  686.                     returns     the object
  687.  
  688.                 :sendsuper <sel> <args>...  SEND SUPERCLASS A MESSAGE
  689.                     <sel>       the message selector
  690.                     <args>      the message arguments
  691.                     returns     the result of sending the message
  692.  
  693.  
  694.  
  695.  
  696.  
  697.  
  698.  
  699.  
  700.  
  701.  
  702.  
  703.  
  704.  
  705.  
  706.  
  707.  
  708.  
  709.  
  710.  
  711.  
  712.  
  713.  
  714.  
  715.  
  716.  
  717.  
  718.  
  719.  
  720.  
  721.  
  722.  
  723.  
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730.  
  731.  
  732.  
  733.  
  734.         XLISP                       OBJECTS                      Page 16
  735.  
  736.  
  737.         THE 'Class' CLASS
  738.  
  739.         Class   THE CLASS OF ALL OBJECT CLASSES (including itself)
  740.  
  741.             Messages:
  742.  
  743.                 :pêOנ£⇦ÿ⇧ÿOßOÉÿOÆ⓪ä⇧ß⓪£⑧OÉ⑧נßO£①ß⇦⇦pננננננננננננננננננננäê⇧Ç⇦ÇäOנננ of levels of trace back information
  744.             o *evalhook* - user substitute for the evaluator function
  745.             o *applyhook* - (not yet implemented)
  746.             o *readtable* - the current readtable
  747.             o *unbound* - indicator for unbound symbols
  748.             o *gc-flag* - controls the printing of gc messages
  749.             o *gc-hook* - function to call after garbage collection
  750.             o *integer-format* - format for printing integers ("%d" or "%ld")
  751.             o *float-format* - format for printing floats ("%g")
  752.             o *print-case* - symbol output case (:upcase or :downcase)
  753.  
  754.         There are several symbols maintained by the read/eval/print
  755.         loop.  The symbols '+', '++', and '+++' are bound to the most
  756.         recent three input expressions.  The symbols '*', '**' and '***'
  757.         are bound to the most recent three results.  The symbol '-' is
  758.         bound to the expression currently being evaluated.  It becomes
  759.         the value of '+' at the end of the evaluation.
  760.  
  761.  
  762.  
  763.  
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  
  770.  
  771.  
  772.  
  773.  
  774.  
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.  
  790.  
  791.  
  792.  
  793.  
  794.         XLISP                 EVALUATION FUNCTIONS               Page 18
  795.  
  796.  
  797.         EVALUATION FUNCTIONS
  798.  
  799.         (eval <expr>)  EVALUATE AN XLISP EXPRESSION
  800.             <expr>      the expression to be evaluated
  801.             returns     the result of evaluating the expression
  802.  
  803.         (apply <fun> <args>)  APPLY A FUNCTION TO A LIST OF ARGUMENTS
  804.             <fun>       the function to apply (or function symbol)
  805.             <args>      the argument list
  806.             returns     the result of applying the function to the arguments
  807.  
  808.         (funcall <fun> <arg>...)  CALL A FUNCTION WITH ARGUMENTS
  809.             <fun>       the function to call (or function symbol)
  810.             <arg>       arguments to pass to the function
  811.             returns     the result of calling the function with the arguments
  812.  
  813.         (quote <expr>)  RETURN AN EXPRESSION UNEVALUATED
  814.             <expr>      the expression to be quoted (quoted)
  815.             returns     <expr> unevaluated
  816.  
  817.         (function <expr>)  GET THE FUNCTIONAL INTERPRETATION
  818.             <expr>      the symbol or lambda expression (quoted)
  819.             returns     the functional interpretation
  820.  
  821.         (backquote <expr>)  FILL IN A TEMPLATE
  822.             <expr>      the template
  823.             returns     a copy of the template with comma and comma-at
  824.                         expressions expanded
  825.  
  826.         (lambda <args> <expr>...)  MAKE A FUNCTION CLOSURE
  827.             <args>      formal argument list (lambda list) (quoted)
  828.             <expr>      expressions of the function body
  829.             returns     the function closure
  830.  
  831.         (get-lambda-expression <closure>)  GET THE LAMBDA EXPRESSION
  832.             <closure>   the closure
  833.             returns     the original lambda expression
  834.  
  835.         (macroexpand <form>)  RECURSIVELY EXPAND MACRO CALLS
  836.             <form>      the form to expand
  837.             returns     the macro expansion
  838.  
  839.         (macroexpand-1 <form>)  EXPAND A MACRO CALL
  840.             <form>      the macro call form
  841.             returns     the macro expansion
  842.  
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.  
  856.  
  857.  
  858.  
  859.  
  860.         XLISP                   SYMBOL FUNCTIONS                 Page 19
  861.  
  862.  
  863.         SYMBOL FUNCTIONS
  864.  
  865.         (set <sym> <expr>)  SET THE VALUE OF A SYMBOL
  866.             <sym>       the symbol being set
  867.             <expr>      the new value
  868.             returns     the new value
  869.  
  870.         (setq [<sym> <expr>]...)  SET THE VALUE OF A SYMBOL
  871.             <sym>       the symbol being set (quoted)
  872.             <expr>      the new value
  873.             returns     the new value
  874.  
  875.         (psetq [<sym> <expr>]...)  PARALLEL VERSION OF SETQ
  876.             <sym>       the symbol being set (quoted)
  877.             <expr>      the new value
  878.             returns     the new value
  879.  
  880.         (setf [<place> <expr>]...)  SET THE VALUE OF A FIELD
  881.             <place>     the field specifier (quoted):
  882.                           <sym>                   set value of a symbol
  883.                           (car <expr>)            set car of a cons node
  884.                           (cdr <expr>)            set cdr of a cons node
  885.                           (nth <n> <expr>)        set nth car of a list
  886.                           (aref <expr> <n>)       set nth element of an array
  887.                           (get <sym> <prop>)      set value of a property
  888.                           (symbol-value <sym>)    set value of a symbol
  889.                           (symbol-function <sym>) set functional value of a symbol
  890.                           (symbol-plist <sym>)    set property list of a symbol
  891.             <value>     the new value
  892.             returns     the new value
  893.  
  894.         (defun <sym> <fargs> <expr>...)  DEFINE A FUNCTION
  895.         (defmacro <sym> <fargs> <expr>...)  DEFINE A MACRO
  896.             <sym>       symbol being defined (quoted)
  897.             <fargs>     formal argument list (lambda list) (quoted)
  898.             <expr>      expressions constituting the body of the
  899.                         function (quoted)
  900.             returns     the function symbol
  901.  
  902.         (gensym [<tag>])  GENERATE A SYMBOL
  903.             <tag>       string or number
  904.             returns     the new symbol
  905.  
  906.         (intern <pname>)  MAKE AN INTERNED SYMBOL
  907.             <pname>     the symbol's print name string
  908.             returns     the new symbol
  909.  
  910.         (make-symbol <pname>)  MAKE AN UNINTERNED SYMBOL
  911.             <pname>     the symbol's print name string
  912.             returns     the new symbol
  913.  
  914.         (symbol-name <sym>)  GET THE PRINT NAME OF A SYMBOL
  915.             <sym>       the symbol
  916.             returns     the symbol's print name
  917.  
  918.  
  919.  
  920.  
  921.  
  922.  
  923.  
  924.  
  925.  
  926.         XLISP                   SYMBOL FUNCTIONS                 Page 20
  927.  
  928.  
  929.         (symbol-value <sym>)  GET THE VALUE OF A SYMBOL
  930.             <sym>       the symbol
  931.             returns     the symbol's value
  932.  
  933.         (symbol-function <sym>)  GET THE FUNCTIONAL VALUE OF A SYMBOL
  934.             <sym>       the symbol
  935.             returns     the symbol's functional value
  936.  
  937.         (symbol-plist <sym>)  GET THE PROPERTY LIST OF A SYMBOL
  938.             <sym>       the symbol
  939.             returns     the symbol's property list
  940.  
  941.         (hash <sym> <n>)  COMPUTE THE HASH INDEX FOR A SYMBOL
  942.             <sym>       the symbol or string
  943.             <n>         the table size (integer)
  944.             returns     the hash index (integer)
  945.  
  946.  
  947.  
  948.  
  949.  
  950.  
  951.  
  952.  
  953.  
  954.  
  955.  
  956.  
  957.  
  958.  
  959.  
  960.  
  961.  
  962.  
  963.  
  964.  
  965.  
  966.  
  967.  
  968.  
  969.  
  970.  
  971.  
  972.  
  973.  
  974.  
  975.  
  976.  
  977.  
  978.  
  979.  
  980.  
  981.  
  982.  
  983.  
  984.  
  985.  
  986.  
  987.  
  988.  
  989.  
  990.  
  991.  
  992.         XLISP               PROPERTY LIST FUNCTIONS              Page 21
  993.  
  994.  
  995.         PROPERTY LIST FUNCTIONS
  996.  
  997.         (get <sym> <prop>)  GET THE VALUE OF A PROPERTY
  998.             <sym>       the symbol
  999.             <prop>      the property symbol
  1000.             returns     the property value or nil
  1001.  
  1002.         (putprop <sym> <val> <prop>)  PUT A PROPERTY ONTO A PROPERTY LIST
  1003.             <sym>       the symbol
  1004.             <val>       the property value
  1005.             <prop>      the property symbol
  1006.             returns     the property value
  1007.  
  1008.         (remprop <sym> <prop>)  REMOVE A PROPERTY
  1009.             <sym>       the symbol
  1010.             <prop>      the property symbol
  1011.             returns     nil
  1012.  
  1013.  
  1014.  
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024.  
  1025.  
  1026.  
  1027.  
  1028.  
  1029.  
  1030.  
  1031.  
  1032.  
  1033.  
  1034.  
  1035.  
  1036.  
  1037.  
  1038.  
  1039.  
  1040.  
  1041.  
  1042.  
  1043.  
  1044.  
  1045.  
  1046.  
  1047.  
  1048.  
  1049.  
  1050.  
  1051.  
  1052.  
  1053.  
  1054.  
  1055.  
  1056.  
  1057.  
  1058.         XLISP                   ARRAY FUNCTIONS                  Page 22
  1059.  
  1060.  
  1061.         ARRAY FUNCTIONS
  1062.  
  1063.         (aref <array> <n>)  GET THE NTH ELEMENT OF AN ARRAY
  1064.             <array>     the array
  1065.             <n>         the array index (integer)
  1066.             returns     the value of the array element
  1067.  
  1068.         (make-array <size>)  MAKE A NEW ARRAY
  1069.             <size>      the size of the new array (integer)
  1070.             returns     the new array
  1071.  
  1072.         (vector <expr>...)  MAKE AN INITIALIZED VECTOR
  1073.             <expr>      the vector elements
  1074.             returns     the new vector
  1075.  
  1076.  
  1077.  
  1078.  
  1079.  
  1080.  
  1081.  
  1082.  
  1083.  
  1084.  
  1085.  
  1086.  
  1087.  
  1088.  
  1089.  
  1090.  
  1091.  
  1092.  
  1093.  
  1094.  
  1095.  
  1096.  
  1097.  
  1098.  
  1099.  
  1100.  
  1101.  
  1102.  
  1103.  
  1104.  
  1105.  
  1106.  
  1107.  
  1108.  
  1109.  
  1110.  
  1111.  
  1112.  
  1113.  
  1114.  
  1115.  
  1116.  
  1117.  
  1118.  
  1119.  
  1120.  
  1121.  
  1122.  
  1123.  
  1124.         XLISP                    LIST FUNCTIONS                  Page 23
  1125.  
  1126.  
  1127.         LIST FUNCTIONS
  1128.  
  1129.         (car <expr>)  RETURN THE CAR OF A LIST NODE
  1130.             <expr>      the list node
  1131.             returns     the car of the list node
  1132.  
  1133.         (cdr <expr>)  RETURN THE CDR OF A LIST NODE
  1134.             <expr>      the list node
  1135.             returns     the cdr of the list node
  1136.  
  1137.         (cxxr <expr>)  ALL CxxR COMBINATIONS
  1138.         (cxxxr <expr>)  ALL CxxxR COMBINATIONS
  1139.         (cxxxxr <expr>)  ALL CxxxxR COMBINATIONS
  1140.  
  1141.         (first <expr>)   A SYNONYM FOR CAR
  1142.         (second <expr>)  A SYNONYM FOR CADR
  1143.         (third <expr>)   A SYNONYM FOR CADDR
  1144.         (fourth <expr>)  A SYNONYM FOR CADDDR
  1145.         (rest <expr>)    A SYNONYM FOR CDR
  1146.  
  1147.         (cons <expr1> <expr2>)  CONSTRUCT A NEW LIST NODE
  1148.             <expr1>     the car of the new list node
  1149.             <expr2>     the cdr of the new list node
  1150.             returns     the new list node
  1151.  
  1152.         (list <expr>...)  CREATE A LIST OF VALUES
  1153.             <expr>      expressions to be combined into a list
  1154.             returns     the new list
  1155.  
  1156.         (append <expr>...)  APPEND LISTS
  1157.             <expr>      lists whose elements are to be appended
  1158.             returns     the new list
  1159.  
  1160.         (reverse <expr>)  REVERSE A LIST
  1161.             <expr>      the list to reverse
  1162.             returns     a new list in the reverse order
  1163.  
  1164.         (last <list>)  RETURN THE LAST LIST NODE OF A LIST
  1165.             <list>      the list
  1166.             returns     the last list node in the list
  1167.  
  1168.         (member <expr> <list> &key :test :test-not)  FIND AN EXPRESSION IN A LIST
  1169.             <expr>      the expression to find
  1170.             <list>      the list to search
  1171.             :test       the test function (defaults to eql)
  1172.             :test-not   the test function (sense inverted)      
  1173.             returns     the remainder of the list starting with the expression
  1174.  
  1175.         (assoc <expr> <alist> &key :test :test-not)  FIND AN EXPRESSION IN AN A-LIST
  1176.             <expr>      the expression to find
  1177.             <alist>     the association list
  1178.             :test       the test function (defaults to eql)
  1179.             :test-not   the test function (sense inverted)      
  1180.             returns     the alist entry or nil
  1181.  
  1182.  
  1183.  
  1184.  
  1185.  
  1186.  
  1187.  
  1188.  
  1189.  
  1190.         XLISP                    LIST FUNCTIONS                  Page 24
  1191.  
  1192.  
  1193.         (remove <expr> <list> &key :test :test-not)  REMOVE ELEMENTS FROM A LIST
  1194.             <expr>      the element to remove
  1195.             <list>      the list
  1196.             :test       the test function (defaults to eql)
  1197.             :test-not   the test function (sense inverted)      
  1198.             returns     copy of list with matching expressions removed
  1199.  
  1200.         (remove-if <test> <list>)  REMOVE ELEMENTS THAT PASS TEST
  1201.             <test>      the test predicate
  1202.             <list>      the list
  1203.             returns     copy of list with matching elements removed
  1204.  
  1205.         (remove-if-not <test> <list>)  REMOVE ELEMENTS THAT FAIL TEST
  1206.             <test>      the test predicate
  1207.             <list>      the list
  1208.             returns     copy of list with non-matching elements removed
  1209.  
  1210.         (length <expr>)  FIND THE LENGTH OF A LIST, VECTOR OR STRING
  1211.             <expr>      the list, vector or string
  1212.             returns     the length of the list, vector or string
  1213.  
  1214.         (nth <n> <list>)  RETURN THE NTH ELEMENT OF A LIST
  1215.             <n>         the number of the element to return (zero origin)
  1216.             <list>      the list
  1217.             returns     the nth element or nil if the list isn't that long
  1218.  
  1219.         (nthcdr <n> <list>)  RETURN THE NTH CDR OF A LIST
  1220.             <n>         the number of the element to return (zero origin)
  1221.             <list>      the list
  1222.             returns     the nth cdr or nil if the list isn't that long
  1223.  
  1224.         (mapc <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CARS
  1225.             <fcn>       the function or function name
  1226.             <listn>     a list for each argument of the function
  1227.             returns     the first list of arguments
  1228.  
  1229.         (mapcar <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CARS
  1230.             <fcn>       the function or function name
  1231.             <listn>     a list for each argument of the function
  1232.             returns     a list of the values returned
  1233.  
  1234.         (mapl <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  1235.             <fcn>       the function or function name
  1236.             <listn>     a list for each argument of the function
  1237.             returns     the first list of arguments
  1238.  
  1239.         (maplist <fcn> <list1> <list>...)  APPLY FUNCTION TO SUCCESSIVE CDRS
  1240.             <fcn>       the function or function name
  1241.             <listn>     a list for each argument of the function
  1242.             returns     a list of the values returned
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.  
  1252.  
  1253.  
  1254.  
  1255.  
  1256.         XLISP                    LIST FUNCTIONS                  Page 25
  1257.  
  1258.  
  1259.         (subst <to> <from> <expr> &key :test :test-not)  SUBSTITUTE EXPRESSIONS
  1260.             <to>        the new expression
  1261.             <from>      the old expression
  1262.             <expr>      the expression in which to do the substitutions
  1263.             :test       the test function (defaults to eql)
  1264.             :test-not   the test function (sense inverted)      
  1265.             returns     the expression with substitutions
  1266.  
  1267.         (sublis <alist> <expr> &key :test :test-not)  SUBSTITUTE WITH AN A-LIST
  1268.             <alist>     the association list
  1269.             <expr>      the expression in which to do the substitutions
  1270.             :test       the test function (defaults to eql)
  1271.             :test-not   the test function (sense inverted)      
  1272.             returns     the expression with substitutions
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.  
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.  
  1322.         XLISP              DESTRUCTIVE LIST FUNCTIONS            Page 26
  1323.  
  1324.  
  1325.         DESTRUCTIVE LIST FUNCTIONS
  1326.  
  1327.         (rplaca <list> <expr>)  REPLACE THE CAR OF A LIST NODE
  1328.             <list>      the list node
  1329.             <expr>      the new value for the car of the list node
  1330.             returns     the list node after updating the car
  1331.  
  1332.         (rplacd <list> <expr>)  REPLACE THE CDR OF A LIST NODE
  1333.             <list>      the list node
  1334.             <expr>      the new value for the cdr of the list node
  1335.             returns     the list node after updating the cdr
  1336.  
  1337.         (nconc <list>...)  DESTRUCTIVELY CONCATENATE LISTS
  1338.             <list>      lists to concatenate
  1339.             returns     the result of concatenating the lists
  1340.  
  1341.         (delete <expr> &key :test :test-not)  DELETE ELEMENTS FROM A LIST
  1342.             <expr>      the element to delete
  1343.             <list>      the list
  1344.             :test       the test function (defaults to eql)
  1345.             :test-not   the test function (sense inverted)      
  1346.             returns     the list with the matching expressions deleted
  1347.  
  1348.         (delete-if <test> <list>)  DELETE ELEMENTS THAT PASS TEST
  1349.             <test>      the test predicate
  1350.             <list>      the list
  1351.             returns     the list with matching elements deleted
  1352.  
  1353.         (delete-if-not <test> <list>)  DELETE ELEMENTS THAT FAIL TEST
  1354.             <test>      the test predicate
  1355.             <list>      the list
  1356.             returns     the list with non-matching elements deleted
  1357.  
  1358.         (sort <list> <test>)  SORT A LIST
  1359.             <list>      the list to sort
  1360.             <test>      the comparison function
  1361.             returns     the sorted list
  1362.  
  1363.  
  1364.  
  1365.  
  1366.  
  1367.  
  1368.  
  1369.  
  1370.  
  1371.  
  1372.  
  1373.  
  1374.  
  1375.  
  1376.  
  1377.  
  1378.  
  1379.  
  1380.  
  1381.  
  1382.  
  1383.  
  1384.  
  1385.  
  1386.  
  1387.  
  1388.         XLISP                 PREDICATE FUNCTIONS                Page 27
  1389.  
  1390.  
  1391.         PREDICATE FUNCTIONS
  1392.  
  1393.         (atom <expr>)  IS THIS AN ATOM?
  1394.             <expr>      the expression to check
  1395.             returns     t if the value is an atom, nil otherwise
  1396.  
  1397.         (symbolp <expr>)  IS THIS A SYMBOL?
  1398.             <expr>      the expression to check
  1399.             returns     t if the expression is a symbol, nil otherwise
  1400.  
  1401.         (numberp <expr>)  IS THIS A NUMBER?
  1402.             <expr>      the expression to check
  1403.             returns     t if the expression is a number, nil otherwise
  1404.  
  1405.         (null <expr>)  IS THIS AN EMPTY LIST?
  1406.             <expr>      the list to check
  1407.             returns     t if the list is empty, nil otherwise
  1408.  
  1409.         (not <expr>)  IS THIS FALSE?
  1410.             <expr>      the expression to check
  1411.             return      t if the value is nil, nil otherwise
  1412.  
  1413.         (listp <expr>)  IS THIS A LIST?
  1414.             <expr>      the expression to check
  1415.             returns     t if the value is a cons or nil, nil otherwise
  1416.  
  1417.         (endp <list>)  IS THIS THE END OF A LIST
  1418.             <list>      the list
  1419.             returns     t if the value is nil, nil otherwise
  1420.  
  1421.         (consp <expr>)  IS THIS A NON-EMPTY LIST?
  1422.             <expr>      the expression to check
  1423.             returns     t if the value is a cons, nil otherwise
  1424.  
  1425.         (integerp <expr>)  IS THIS AN INTEGER?
  1426.             <expr>      the expression to check
  1427.             returns     t if the value is an integer, nil otherwise
  1428.  
  1429.         (floatp <expr>)  IS THIS A FLOAT?
  1430.             <expr>      the expression to check
  1431.             returns     t if the value is a float, nil otherwise
  1432.  
  1433.         (stringp <expr>)  IS THIS A STRING?
  1434.             <expr>      the expression to check
  1435.             returns     t if the value is a string, nil otherwise
  1436.  
  1437.         (characterp <expr>)  IS THIS A CHARACTER?
  1438.             <expr>      the expression to check
  1439.             returns     t if the value is a character, nil otherwise
  1440.  
  1441.         (arrayp <expr>)  IS THIS AN ARRAY?
  1442.             <expr>      the expression to check
  1443.             returns     t if the value is an array, nil otherwise
  1444.  
  1445.  
  1446.  
  1447.  
  1448.  
  1449.  
  1450.  
  1451.  
  1452.  
  1453.  
  1454.         XLISP                 PREDICATE FUNCTIONS                Page 28
  1455.  
  1456.  
  1457.         (streamp <expr>)  IS THIS A STREAM?
  1458.             <expr>      the expression to check
  1459.             returns     t if the value is a stream, nil otherwise
  1460.  
  1461.         (objectp <expr>)  IS THIS AN OBJECT?
  1462.             <expr>      the expression to check
  1463.             returns     t if the value is an object, nil otherwise
  1464.  
  1465.         (boundp <sym>)  IS A VALUE BOUND TO THIS SYMBOL?
  1466.             <sym>       the symbol
  1467.             returns     t if a value is bound to the symbol, nil otherwise
  1468.  
  1469.         (fboundp <sym>)  IS A FUNCTIONAL VALUE BOUND TO THIS SYMBOL?
  1470.             <sym>       the symbol
  1471.             returns     t if a functional value is bound to the symbol,
  1472.                         nil otherwise
  1473.  
  1474.         (minusp <expr>)  IS THIS NUMBER NEGATIVE?
  1475.             <expr>      the number to test
  1476.             returns     t if the number is negative, nil otherwise
  1477.  
  1478.         (zerop <expr>)  IS THIS NUMBER ZERO?
  1479.             <expr>      the number to test
  1480.             returns     t if the number is zero, nil otherwise
  1481.  
  1482.         (plusp <expr>)  IS THIS NUMBER POSITIVE?
  1483.             <expr>      the number to test
  1484.             returns     t if the number is positive, nil otherwise
  1485.  
  1486.         (evenp <expr>)  IS THIS INTEGER EVEN?
  1487.             <expr>      the integer to test
  1488.             returns     t if the integer is even, nil otherwise
  1489.  
  1490.         (oddp <expr>)  IS THIS INTEGER ODD?
  1491.             <expr>      the integer to test
  1492.             returns     t if the integer is odd, nil otherwise
  1493.  
  1494.         (eq <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1495.             <expr1>     the first expression
  1496.             <expr2>     the second expression
  1497.             returns     t if they are equal, nil otherwise
  1498.  
  1499.         (eql <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1500.                                 (WORKS WITH ALL NUMBERS)
  1501.             <expr1>     the first expression
  1502.             <expr2>     the second expression
  1503.             returns     t if they are equal, nil otherwise
  1504.  
  1505.         (equal <expr1> <expr2>)  ARE THE EXPRESSIONS EQUAL?
  1506.             <expr1>     the first expression
  1507.             <expr2>     the second expression
  1508.             returns     t if they are equal, nil otherwise
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520.         XLISP                  CONTROL CONSTRUCTS                Page 29
  1521.  
  1522.  
  1523.         CONTROL CONSTRUCTS
  1524.  
  1525.         (cond <pair>...)  EVALUATE CONDITIONALLY
  1526.             <pair>      pair consisting of:
  1527.                             (<pred> <expr>...)
  1528.                           where
  1529.                             <pred>      is a predicate expression
  1530.                             <expr>      evaluated if the predicate
  1531.                                         is not nil
  1532.             returns     the value of the first expression whose predicate
  1533.                         is not nil
  1534.  
  1535.         (and <expr>...)  THE LOGICAL AND OF A LIST OF EXPRESSIONS
  1536.             <expr>      the expressions to be ANDed
  1537.             returns     nil if any expression evaluates to nil,
  1538.                         otherwise the value of the last expression
  1539.                         (evaluation of expressions stops after the first
  1540.                          expression that evaluates to nil)
  1541.  
  1542.         (or <expr>...)  THE LOGICAL OR OF A LIST OF EXPRESSIONS
  1543.             <expr>      the expressions to be ORed
  1544.             returns     nil if all expressions evaluate to nil,
  1545.                         otherwise the value of the first non-nil expression
  1546.                         (evaluation of expressions stops after the first
  1547.                          expression that does not evaluate to nil)
  1548.  
  1549.         (if <texpr> <expr1> [<expr2>])  EVALUATE EXPRESSIONS CONDITIONALLY
  1550.             <texpr>     the test expression
  1551.             <expr1>     the expression to be evaluated if texpr is non-nil
  1552.             <expr2>     the expression to be evaluated if texpr is nil
  1553.             returns     the value of the selected expression
  1554.  
  1555.         (when <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS TRUE
  1556.             <texpr>     the test expression
  1557.             <expr>      the expression(s) to be evaluted if texpr is non-nil
  1558.             returns     the value of the last expression or nil
  1559.  
  1560.         (unless <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS FALSE
  1561.             <texpr>     the test expression
  1562.             <expr>      the expression(s) to be evaluated if texpr is nil
  1563.             returns     the value of the last expression or nil
  1564.  
  1565.           (case <expr> <case>...)  SELECT BY CASE
  1566.             <expr>      the selection expression
  1567.             <case>      pair consisting of:
  1568.                             (<value> <expr>...)
  1569.                           where:
  1570.                             <value>     is a single expression or a list of
  1571.                                         expressions (unevaluated)
  1572.                             <expr>      are expressions to execute if the
  1573.                                         case matches
  1574.             returns     the value of the last expression of the matching case
  1575.  
  1576.  
  1577.  
  1578.  
  1579.  
  1580.  
  1581.  
  1582.  
  1583.  
  1584.  
  1585.  
  1586.         XLISP                  CONTROL CONSTRUCTS                Page 30
  1587.  
  1588.  
  1589.         (let (<binding>...) <expr>...)  CREATE LOCAL BINDINGS
  1590.         (let* (<binding>...) <expr>...)  LET WITH SEQUENTIAL BINDING
  1591.             <binding>   the variable bindings each of which is either:
  1592.                         1)  a symbol (which is initialized to nil)
  1593.                         2)  a list whose car is a symbol and whose cadr
  1594.                                 is an initialization expression
  1595.             <expr>      the expressions to be evaluated
  1596.             returns     the value of the last expression
  1597.  
  1598.         (flet (<binding>...) <expr>...)  CREATE LOCAL FUNCTIONS
  1599.         (labels (<binding>...) <expr>...)  FLET WITH RECURSIVE FUNCTIONS
  1600.         (macrolet (<binding>...) <expr>...)  CREATE LOCAL MACROS
  1601.             <binding>   the function bindings each of which is:
  1602.                           (<sym> <fargs> <expr>...)
  1603.                         where:
  1604.                             <sym>       the function/macro name
  1605.                             <fargs>     formal argument list (lambda list)
  1606.                             <expr>      expressions constituting the body of
  1607.                                         the function/macro
  1608.             <expr>      the expressions to be evaluated
  1609.             returns     the value of the last expression
  1610.  
  1611.         (catch <sym> <expr>...)  EVALUATE EXPRESSIONS AND CATCH THROWS
  1612.             <sym>       the catch tag
  1613.             <expr>      expressions to evaluate
  1614.             returns     the value of the last expression the throw expression
  1615.  
  1616.         (throw <sym> [<expr>])  THROW TO A CATCH
  1617.             <sym>       the catch tag
  1618.             <expr>      the value for the catch to return (defaults to nil)
  1619.             returns     never returns
  1620.  
  1621.         (unwind-protect <expr> <cexpr>...)  PROTECT EVALUATION OF AN EXPRESSION
  1622.             <expr>      the expression to protect
  1623.             <cexpr>     the cleanup expressions
  1624.             returns     the value of the expression
  1625.           Note:  unwind-protect guarantees to execute the cleanup expressions
  1626.                  even if a non-local exit terminates the evaluation of the
  1627.                  protected expression
  1628.  
  1629.  
  1630.  
  1631.  
  1632.  
  1633.  
  1634.  
  1635.  
  1636.  
  1637.  
  1638.  
  1639.  
  1640.  
  1641.  
  1642.  
  1643.  
  1644.  
  1645.  
  1646.  
  1647.  
  1648.  
  1649.  
  1650.  
  1651.  
  1652.         XLISP                  LOOPING CONSTRUCTS                Page 31
  1653.  
  1654.  
  1655.         LOOPING CONSTRUCTS
  1656.  
  1657.         (loop <expr>...)  BASIC LOOPING FORM
  1658.             <expr>      the body of the loop
  1659.             returns     never returns (must use non-local exit)
  1660.  
  1661.         (do (<binding>...) (<texpr> <rexpr>...) <expr>...)
  1662.         (do* (<binding>...) (<texpr> <rexpr>...) <expr>...)
  1663.             <binding>   the variable bindings each of which is either:
  1664.                         1)  a symbol (which is initialized to nil)
  1665.                         2)  a list of the form: (<sym> <init> [<step>])
  1666.                             where:
  1667.                                 <sym>  is the symbol to bind
  1668.                                 <init> is the initial value of the symbol
  1669.                                 <süê◆ijנé⇦OÄOä⇧ê◆נê⇨çäê⇦⇦⇩≡ננננננננננננIJüê⇨çäijנננננüâêOüê⇦Ç⇩Ä⇧éנüê⇦⇧נê⇨çäê⇦⇦⇩≡ננננננננננננIJäê⇨çäijנננננäê⇦⇧üנê⇨çäê⇦⇦⇩äOבüâêOëê✓Ä⇧üנé⇦OÇé⇧אpננננננננננננIJê⇨çäijננננננüâêOîÇ    éOÇ✓נüâêOüÇ◆נבüäê⇧ê    נüé✓OÄנé◆üé ⇩⇧נçäÇ✓Bpננננננ     (streamp <expr>)  IS THIS A STREAM?
  1670.             <expr>      the expression to check
  1671.             returns     t if the value is a stream, nil otherwise
  1672.  
  1673.         (objectp <expr>)  IS THIS AN OBJECT?
  1674.             <expr>      the expression to check
  1675.             returns     t if the value is an object, nil otherwise
  1676.  
  1677.         (boundp <sym>)  IS A VALUE BOUND TO THIS SYMBOL?
  1678.             <sym>       the symbol
  1679.             returns     t if a value is bound to the symbol, nil otherwise
  1680.  
  1681.         (fboundp <sym>)  IS A FUNCTIONAL VALUE BOUND TO THIS SYMBOL?
  1682.             <sym>       the symbol
  1683.             returns     t if a functional value is bound to the symbol,
  1684.                         nil otherwise
  1685.  
  1686.         (minusp <expr>)  IS THIS NUMBER NEGATIVE?
  1687.             <expr>      the number to test
  1688.             returns     t if the number is negative, nil otherwise
  1689.  
  1690.         (zerop <expr>)  IS THIS NUMBER ZERO?
  1691.             <expr>      the number to test
  1692.             returns     t if the number is zero, nil otherwise
  1693.  
  1694.         (plusp <expr>)  IS THIS NUMBER POSITIVE?
  1695.             <expr>      the number to test
  1696.             returns     t if the number is positive, nil otherwise
  1697.  
  1698.         (evenp <expr>)  IS THIS INTEGER EVEN?
  1699.             <expr>      the integer to test
  1700.             returns     t if the integer is even, nil otherwise
  1701.  
  1702.         (oddp <expr>)  IS THIS INTEGER ODD?
  1703.             <expr>      the integer to test
  1704.             returns     t if the integer is odd, nil otherwise
  1705.  
  1706.         (eq <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1707.             <expr1>     the first expression
  1708.             <expr2>     the second expression
  1709.             returns     t if they are equal, nil otherwise
  1710.  
  1711.         (eql <expr1> <expr2>)  ARE THE EXPRESSIONS IDENTICAL?
  1712.                                 (WORKS WITH ALL NUMBERS)
  1713.             <expr1>     the first expression
  1714.             <expr2>     the second expression
  1715.             returns     t if they are equal, nil otherwise
  1716.  
  1717.         (equal <expr1> <expr2>)  ARE THE EXPRESSIONS EQUAL?
  1718.             <expr1>     the first expression
  1719.             <expr2>     the second expression
  1720.             returns     t if they are equal, nil otherwise
  1721.  
  1722.  
  1723.  
  1724.  
  1725.  
  1726.  
  1727.  
  1728.  
  1729.  
  1730.  
  1731.  
  1732.         XLISP                  CONTROL CONSTRUCTS                Page 29
  1733.  
  1734.  
  1735.         CONTROL CONSTRUCTS
  1736.  
  1737.         (cond <pair>...)  EVALUATE CONDITIONALLY
  1738.             <pair>      pair consisting of:
  1739.                             (<pred> <expr>...)
  1740.                           where
  1741.                             <pred>      is a predicate expression
  1742.                             <expr>      evaluated if the predicate
  1743.                                         is not nil
  1744.             returns     the value of the first expression whose predicate
  1745.                         is not nil
  1746.  
  1747.         (and <expr>...)  THE LOGICAL AND OF A LIST OF EXPRESSIONS
  1748.             <expr>      the expressions to be ANDed
  1749.             returns     nil if any expression evaluates to nil,
  1750.                         otherwise the value of the last expression
  1751.                         (evaluation of expressions stops after the first
  1752.                          expression that evaluates to nil)
  1753.  
  1754.         (or <expr>...)  THE LOGICAL OR OF A LIST OF EXPRESSIONS
  1755.             <expr>      the expressions to be ORed
  1756.             returns     nil if all expressions evaluate to nil,
  1757.                         otherwise the value of the first non-nil expression
  1758.                         (evaluation of expressions stops after the first
  1759.                          expression that does not evaluate to nil)
  1760.  
  1761.         (if <texpr> <expr1> [<expr2>])  EVALUATE EXPRESSIONS CONDITIONALLY
  1762.             <texpr>     the test expression
  1763.             <expr1>     the expression to be evaluated if texpr is non-nil
  1764.             <expr2>     the expression to be evaluated if texpr is nil
  1765.             returns     the value of the selected expression
  1766.  
  1767.         (when <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS TRUE
  1768.             <texpr>     the test expression
  1769.             <expr>      the expression(s) to be evaluted if texpr is non-nil
  1770.             returns     the value of the last expression or nil
  1771.  
  1772.         (unless <texpr> <expr>...)  EVALUATE ONLY WHEN A CONDITION IS FALSE
  1773.             <texpr>     the test expression
  1774.             <expr>      the expression(s) to be evaluated if texpr is nil
  1775.             returns     the value of the last expression or nil
  1776.  
  1777.           (case <expr> <case>...)  SELECT BY CASE
  1778.             <expr>      the selection expression
  1779.             <case>      pair consisting of:
  1780.                             (<value> <expr>...)
  1781.                           where:
  1782.                             <value>     is a single expression or a list of
  1783.                                         expressions (unevaluated)
  1784.                             <expr>      are expressions to execute if the
  1785.                                         case matches
  1786.             returns     the value of the last expression of the matching case
  1787.  
  1788.  
  1789.  
  1790.  
  1791.  
  1792.  
  1793.  
  1794.  
  1795.  
  1796.  
  1797.  
  1798.         XLISP                  CONTROL CONSTRUCTS                Page 30
  1799.  
  1800.  
  1801.         (let (<binding>...) <expr>...)  CREATE LOCAL BINDINGS
  1802.         (let* (<binding>...) <expr>...)  LET WITH SEQUENTIAL BINDING
  1803.             <binding>   the variable bindings each of which is either:
  1804.                         1)  a symbol (which is initialized to nil)
  1805.                         2)  a list whose car is a symbol and whose cadr
  1806.                                 is an initialization expression
  1807.             <expr>      the expressions to be evaluated
  1808.             returns     the value of the last expression
  1809.  
  1810.         (flet (<binding>...) <expr>...)  CREATE LOCAL FUNCTIONS
  1811.         (labels (<binding>...) <expr>...)  FLET WITH RECURSIVE FUNCTIONS
  1812.         (macrolet (<binding>...) <expr>...)  CREATE LOCAL MACROS
  1813.             <binding>   the function bindings each of which is:
  1814.                           (<sym> <fargs> <expr>...)
  1815.                         where:
  1816.                             <sym>       the function/macro name
  1817.                             <fargs>     formal argument list (lambda list)
  1818.                             <expr>      expressions constituting the body of
  1819.                                         the function/macro
  1820.             <expr>      the expressions to be evaluated
  1821.             returns     the value of the last expression
  1822.  
  1823.         (catch <sym> <expr>...)  EVALUATE EXPRESSIONS AND CATCH THROWS
  1824.             <sym>       the catch tag
  1825.             <expr>      expressions to evaluate
  1826.             returns     the value of the last expression the throw expression
  1827.  
  1828.         (throw <sym> [<expr>])  THROW TO A CATCH
  1829.             <sym>       the catch tag
  1830.             <expr>      the value for the catch to return (defaults to nil)
  1831.             returns     never returns
  1832.  
  1833.         (unwind-protect <expr> <cexpr>...)  PROTECT EVALUATION OF AN EXPRESSION
  1834.             <expr>      the expression to protect
  1835.             <cexpr>     the cleanup expressions
  1836.             returns     the value of the expression
  1837.           Note:  unwind-protect guarantees to execute the cleanup expressions
  1838.                  even if a non-local exit terminates the evaluation of the
  1839.                  protected expression
  1840.  
  1841.  
  1842.  
  1843.  
  1844.  
  1845.  
  1846.  
  1847.  
  1848.  
  1849.  
  1850.  
  1851.  
  1852.  
  1853.  
  1854.  
  1855.  
  1856.  
  1857.  
  1858.  
  1859.  
  1860. est number in the list
  1861.  
  1862.         (max <expr>...)  THE LARGEST OF A LIST OF NUMBERS
  1863.             <expr>      the expressions to be checked
  1864.             returns     the largest number in the list
  1865.  
  1866.         (abs <expr>)  THE ABSOLUTE VALUE OF A NUMBER
  1867.             <expr>      the number
  1868.             returns     the absolute value of the number
  1869.  
  1870.         (gcd <n1> <n2>...)  COMPUTE THE GREATEST COMMON DIVISOR
  1871.             <n1>        the first number (integer)
  1872.             <n2>        the second number(s) (integer)
  1873.             returns     the greatest common divisor
  1874.  
  1875.  
  1876.  
  1877.  
  1878.  
  1879.  
  1880.  
  1881.  
  1882.  
  1883.         XLISP                 ARITHMETIC FUNCTIONS               Page 35
  1884.  
  1885.  
  1886.         (random <n>)  COMPUTE A RANDOM NUMBER BETWEEN 1 and N-1
  1887.             <n>         the upper bound (integer)
  1888.             returns     a random number
  1889.  
  1890.         (sin <expr>)  COMPUTE THE SINE OF A NUMBER
  1891.             <expr>      the floating point number
  1892.             returns     the sine of the number
  1893.  
  1894.         (cos <expr>)  COMPUTE THE COSINE OF A NUMBER
  1895.             <expr>      the floating point number
  1896.             returns     the cosine of the number
  1897.  
  1898.         (tan <expr>)  COMPUTE THE TANGENT OF A NUMBER
  1899.             <expr>      the floating point number
  1900.             returns     the tangent of the number
  1901.  
  1902.         (expt <x-expr> <y-expr>)  COMPUTE X TO THE Y POWER
  1903.             <x-expr>    the floating point number
  1904.             <y-expr>    the floating point exponent
  1905.             returns     x to the y power
  1906.  
  1907.         (exp <x-expr>)  COMPUTE E TO THE X POWER
  1908.             <x-expr>    the floating point number
  1909.             returns     e to the x power
  1910.  
  1911.         (sqrt <expr>)  COMPUTE THE SQUARE ROOT OF A NUMBER
  1912.             <expr>      the floating point number
  1913.             returns     the square root of the number
  1914.  
  1915.         (< <n1> <n2>...)  TEST FOR LESS THAN
  1916.         (<= <n1> <n2>...)  TEST FOR LESS THAN OR EQUAL TO
  1917.         (= <n1> <n2>...)  TEST FOR EQUAL TO
  1918.         (/= <n1> <n2>...)  TEST FOR NOT EQUAL TO
  1919.         (>= <n1> <n2>...)  TEST FOR GREATER THAN OR EQUAL TO
  1920.         (> <n1> <n2>...)  TEST FOR GREATER THAN
  1921.             <n1>        the first number to compare
  1922.             <n2>        the second number to compare
  1923.             returns     the result of comparing <n1> with <n2>...
  1924.  
  1925.  
  1926.  
  1927.  
  1928.  
  1929.  
  1930.  
  1931.  
  1932.  
  1933.  
  1934.  
  1935.  
  1936.  
  1937.  
  1938.  
  1939.  
  1940.  
  1941.  
  1942.  
  1943.  
  1944.  
  1945.  
  1946.  
  1947.  
  1948.  
  1949.         XLISP              BITWISE LOGICAL FUNCTIONS             Page 36
  1950.  
  1951.  
  1952.         BITWISE LOGICAL FUNCTIONS
  1953.  
  1954.         (logand <expr>...)  THE BITWISE AND OF A LIST OF NUMBERS
  1955.             <expr>      the numbers
  1956.             returns     the result of the and operation
  1957.  
  1958.         (logior <expr>...)  THE BITWISE INCLUSIVE OR OF A LIST OF NUMBERS
  1959.             <expr>      the numbers
  1960.             returns     the result of the inclusive or operation
  1961.  
  1962.         (logxor <expr>...)  THE BITWISE EXCLUSIVE OR OF A LIST OF NUMBERS
  1963.             <expr>      the numbers
  1964.             returns     the result of the exclusive or operation
  1965.  
  1966.         (lognot <expr>)  THE BITWISE NOT OF A NUMBER
  1967.             <expr>      the number
  1968.             returns     the bitwise inversion of number
  1969.  
  1970.  
  1971.  
  1972.  
  1973.  
  1974.  
  1975.  
  1976.  
  1977.  
  1978.  
  1979.  
  1980.  
  1981.  
  1982.  
  1983.  
  1984.  
  1985.  
  1986.  
  1987.  
  1988.  
  1989.  
  1990.  
  1991.  
  1992.  
  1993.  
  1994.  
  1995.  
  1996.  
  1997.  
  1998.  
  1999.  
  2000.  
  2001.  
  2002.  
  2003.  
  2004.  
  2005.  
  2006.  
  2007.  
  2008.  
  2009.  
  2010.  
  2011.  
  2012.  
  2013.  
  2014.  
  2015.         XLISP                   STRING FUNCTIONS                 Page 37
  2016.  
  2017.  
  2018.         STRING FUNCTIONS
  2019.  
  2020.         (string <expr>)  MAKE A STRING FROM AN INTEGER ASCII VALUE
  2021.             <expr>      the integer
  2022.             returns     a one character string
  2023.  
  2024.         (string-trim <bag> <str>)  TRIM BOTH ENDS OF A STRING
  2025.             <bag>       a string containing characters to trim
  2026.             <str>       the string to trim
  2027.             returns     a trimed copy of the string
  2028.  
  2029.         (string-left-trim <bag> <str>)  TRIM THE LEFT END OF A STRING
  2030.             <bag>       a string containing characters to trim
  2031.             <str>       the string to trim
  2032.             returns     a trimed copy of the string
  2033.  
  2034.         (string-right-trim <bag> <str>)  TRIM THE RIGHT END OF A STRING
  2035.             <bag>       a string containing characters to trim
  2036.             <str>       the string to trim
  2037.             returns     a trimed copy of the string
  2038.  
  2039.         (string-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2040.             <str>       the string
  2041.             :start      the starting offset
  2042.             :end        the ending offset + 1
  2043.             returns     a converted copy of the string
  2044.  
  2045.         (string-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2046.             <str>       the string
  2047.             :start      the starting offset
  2048.             :end        the ending offset + 1
  2049.             returns     a converted copy of the string
  2050.  
  2051.         (nstring-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2052.             <str>       the string
  2053.             :start      the starting offset
  2054.             :end        the ending offset + 1
  2055.             returns     the converted string (not a copy)
  2056.  
  2057.         (nstring-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2058.             <str>       the string
  2059.             :start      the starting offset
  2060.             :end        the ending offset + 1
  2061.             returns     the converted string (not a copy)
  2062.  
  2063.         (strcat <expr>...)  CONCATENATE STRINGS
  2064.             <expr>      the strings to concatenate
  2065.             returns     the result of concatenating the strings
  2066.  
  2067.         (subseq <string> <start> [<end>]) EXTRACT A SUBSTRING
  2068.             <string>    the string
  2069.             <start>     the starting position (zero origin)
  2070.             <end>       the ending position + 1 (defaults to end)
  2071.             returns     substring between <start> and <end>
  2072.  
  2073.  
  2074.  
  2075.  
  2076.  
  2077.  
  2078.  
  2079.  
  2080.  
  2081.         XLISP                   STRING FUNCTIONS                 Page 38
  2082.  
  2083.  
  2084.         (string< <str1> <str2> &key :start1 :end1 :start2 :end2)
  2085.         (string<= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2086.         (string= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2087.         (string/= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2088.         (string>= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2089.         (string> <str1> <str2> &key :start1 :end1 :start2 :end2)
  2090.             <str1>      the first string to compare
  2091.             <str2>      the second string to compare
  2092.             :start1     first substring starting offset
  2093.             :end1       first substring ending offset + 1
  2094.             :start2     second substring starting offset
  2095.             :end2       second substring ending offset + 1
  2096.             returns     t if predicate is true, nil otherwise
  2097.           Note: case is significant with these comparison functions.
  2098.  
  2099.         (string-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2100.         (string-not-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2101.         (string-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2102.         (string-not-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2103.         (string-not-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2104.         (string-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2105.             <str1>      the first string to compare
  2106.             <str2>      the second string to compare
  2107.             :start1     first substring starting offset
  2108.             :end1       first substring ending offset + 1
  2109.             :start2     second substring starting offset
  2110.             :end2       second substring ending offset + 1
  2111.             returns     t if predicate is true, nil otherwise
  2112.           Note: case is not significant with these comparison functions.
  2113.  
  2114.  
  2115.  
  2116.  
  2117.  
  2118.  
  2119.  
  2120.  
  2121.  
  2122.  
  2123.  
  2124.  
  2125.  
  2126.  
  2127.  
  2128.  
  2129.  
  2130.  
  2131.  
  2132.  
  2133.  
  2134.  
  2135.  
  2136.  
  2137.  
  2138.  
  2139.  
  2140.  
  2141.  
  2142.  
  2143.  
  2144.  
  2145.  
  2146.  
  2147.         XLISP                 CHARACTER FUNCTIONS                Page 39
  2148.  
  2149.  
  2150.         CHARACTER FUNCTIONS
  2151.  
  2152.         (char <string> <index>)  EXTRACT A CHARACTER FROM A STRING
  2153.             <string>    the string
  2154.             <index>     the string index (zero relative)
  2155.             returns     the ascii code of the character
  2156.  
  2157.         (upper-case-p <chr>)  IS THIS AN UPPER CASE CHARACTER?
  2158.             <chr>       the character
  2159.             returns     true if the character is upper case, nil otherwise
  2160.  
  2161.         (lower-case-p <chr>)  IS THIS A LOWER CASE CHARACTER?
  2162.             <chr>       the character
  2163.             returns     true if the character is lower case, nil otherwise
  2164.  
  2165.         (both-case-p <chr>)  IS THIS AN ALPHABETIC (EITHER CASE) CHARACTER?
  2166.             <chr>       the character
  2167.             returns     true if the character is alphabetic, nil otherwise
  2168.  
  2169.         (digit-char-p <chr>)  IS THIS A DIGIT CHARACTER?
  2170.             <chr>       the character
  2171.             returns     the digit weight if character is a digit, nil otherwise
  2172.  
  2173.         (char-code <chr>)  GET THE ASCII CODE OF A CHARACTER
  2174.             <chr>       the character
  2175.             returns     the ASCII character code (integer)
  2176.  
  2177.         (code-char <code>)  GET THE CHARACTER WITH A SPECFIED ASCII CODE
  2178.             <code>      the ASCII code (integer)
  2179.             returns     the character with that code or nil
  2180.  
  2181.         (char-upcase <chr>)  CONVERT A CHARACTER TO UPPER CASE
  2182.             <chr>       the character
  2183.             returns     the upper case character
  2184.  
  2185.         (char-downcase <chr>)  CONVERT A CHARACTER TO LOWER CASE
  2186.             <chr>       the character
  2187.             returns     the lower case character
  2188.  
  2189.         (digit-char <n>)  CONVERT A DIGIT WEIGHT TO A DIGIT
  2190.             <n>         the digit weight (integer)
  2191.             returns     the digit character or nil
  2192.  
  2193.         (char-int <chr>) CONVERT A CHARACTER TO AN INTEGER
  2194.             <chr>       the character
  2195.             returns     the ASCII character code
  2196.  
  2197.         (int-char <int>) CONVERT AN INTEGER TO A CHARACTER
  2198.             <int>       the ASCII character code
  2199.             returns     the character with that code
  2200.  
  2201.  
  2202.  
  2203.  
  2204.  
  2205.  
  2206.  
  2207.  
  2208.  
  2209.  
  2210.  
  2211.  
  2212.  
  2213.         XLISP                 CHARACTER FUNCTIONS                Page 40
  2214.  
  2215.  
  2216.         (char< <chr1> <chr2>...)
  2217.         (char<= <chr1> <chr2>...)
  2218.         (char= <chr1> <chr2>...)
  2219.         (char/= <chr1> <chr2>...)
  2220.         (char>= <chr1> <chr2>...)
  2221.         (char> <chr1> <chr2>...)
  2222.             <chr1>      the first character to compare
  2223.             <chr2>      the second character(s) to compare
  2224.             returns     t if predicate is true, nil otherwise
  2225.           Note: case is significant with these comparison functions.
  2226.  
  2227.         (char-lessp <chr1> <chr2>...)
  2228.         (char-not-greaterp <chr1> <chr2>...)
  2229.         (char-equalp <chr1> <chr2>...)
  2230.         (char-not-equalp <chr1> <chr2>...)
  2231.         (char-not-lessp <chr1> <chr2>...)
  2232.         (char-greaterp <chr1> <chr2>...)
  2233.             <chr1>      the first string to compare
  2234.             <chr2>      the second string(s) to compare
  2235.             returns     t if predicate is true, nil otherwise
  2236.           Note: case is not significant with these comparison functions.
  2237.  
  2238.  
  2239.  
  2240.  
  2241.  
  2242.  
  2243.  
  2244.  
  2245.  
  2246.  
  2247.  
  2248.  
  2249.  
  2250.  
  2251.  
  2252.  
  2253.  
  2254.  
  2255.  
  2256.  
  2257.  
  2258.  
  2259.  
  2260.  
  2261.  
  2262.  
  2263.  
  2264.  
  2265.  
  2266.  
  2267.  
  2268.  
  2269.  
  2270.  
  2271.  
  2272.  
  2273.  
  2274.  
  2275.  
  2276.  
  2277.  
  2278.  
  2279.         XLISP                INPUT/OUTPUT FUNCTIONS              Page 41
  2280.  
  2281.  
  2282.         INPUT/OUTPUT FUNCTIONS
  2283.  
  2284.         (read [<stream> [<eof> [<rflag>]]])  READ AN EXPRESSION
  2285.             <stream>    the input stream (default is standard input)
  2286.             <eof>       the value to return oÇנêëנÇ✓נêé⇧êOבëê✓Ä⇧üנé⇦OÇé⇧אpננננננננננננIJäêüÄ✓@נננננäê ⇦ä⇩êOäê    נêüÄ✓Oבëê✓Ä⇧üנé⇦OÇé⇧אpננננננננננננäê⇧Ç⇦ÇäOננננüâêOê⇨çäê⇦⇦⇩נäê    ≡≡ננננננננבçäéüנIJê⇨çäijנÇAä⇧äê@ÇBOנçäÆ⓪üנß⓪נÿ⇨çäÿ⇦⇦②⓪⓪נÉ⓪נßOÉÿOæÆ⓪ÿpננננננננננננIJê⇨çäijננננננüâêOê⇨çäê⇦⇦⇩נüÇOîêOçäéüê    ≡ננננננננננננIJä⇧äê@ננננüâêOÇ⇧çÇ⇧נä⇧äêOבëê✓Ä⇧üנé⇦Oä⇧ÄëÄ⇦ëנÇ⇧çÇ⇧אpננננננננננננäê⇧Ç⇦ÇäOננננüâêOê⇨çäê⇦⇦⇩≡≡ננננננננבçäéהOIJê⇨çäijנÇAä⇧äê
  2287.  
  2288.  
  2289.         XLISP                   STRING FUNCTIONS                 Page 37
  2290.  
  2291.  
  2292.         STRING FUNCTIONS
  2293.  
  2294.         (string <expr>)  MAKE A STRING FROM AN INTEGER ASCII VALUE
  2295.             <expr>      the integer
  2296.             returns     a one character string
  2297.  
  2298.         (string-trim <bag> <str>)  TRIM BOTH ENDS OF A STRING
  2299.             <bag>       a string containing characters to trim
  2300.             <str>       the string to trim
  2301.             returns     a trimed copy of the string
  2302.  
  2303.         (string-left-trim <bag> <str>)  TRIM THE LEFT END OF A STRING
  2304.             <bag>       a string containing characters to trim
  2305.             <str>       the string to trim
  2306.             returns     a trimed copy of the string
  2307.  
  2308.         (string-right-trim <bag> <str>)  TRIM THE RIGHT END OF A STRING
  2309.             <bag>       a string containing characters to trim
  2310.             <str>       the string to trim
  2311.             returns     a trimed copy of the string
  2312.  
  2313.         (string-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2314.             <str>       the string
  2315.             :start      the starting offset
  2316.             :end        the ending offset + 1
  2317.             returns     a converted copy of the string
  2318.  
  2319.         (string-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2320.             <str>       the string
  2321.             :start      the starting offset
  2322.             :end        the ending offset + 1
  2323.             returns     a converted copy of the string
  2324.  
  2325.         (nstring-upcase <str> &key :start :end)  CONVERT TO UPPERCASE
  2326.             <str>       the string
  2327.             :start      the starting offset
  2328.             :end        the ending offset + 1
  2329.             returns     the converted string (not a copy)
  2330.  
  2331.         (nstring-downcase <str> &key :start :end)  CONVERT TO LOWERCASE
  2332.             <str>       the string
  2333.             :start      the starting offset
  2334.             :end        the ending offset + 1
  2335.             returns     the converted string (not a copy)
  2336.  
  2337.         (strcat <expr>...)  CONCATENATE STRINGS
  2338.             <expr>      the strings to concatenate
  2339.             returns     the result of concatenating the strings
  2340.  
  2341.         (subseq <string> <start> [<end>]) EXTRACT A SUBSTRING
  2342.             <string>    the string
  2343.             <start>     the starting position (zero origin)
  2344.             <end>       the ending position + 1 (defaults to end)
  2345.             returns     substring between <start> and <end>
  2346.  
  2347.  
  2348.  
  2349.  
  2350.  
  2351.  
  2352.  
  2353.  
  2354.  
  2355.         XLISP                   STRING FUNCTIONS                 Page 38
  2356.  
  2357.  
  2358.         (string< <str1> <str2> &key :start1 :end1 :start2 :end2)
  2359.         (string<= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2360.         (string= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2361.         (string/= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2362.         (string>= <str1> <str2> &key :start1 :end1 :start2 :end2)
  2363.         (string> <str1> <str2> &key :start1 :end1 :start2 :end2)
  2364.             <str1>      the first string to compare
  2365.             <str2>      the second string to compare
  2366.             :start1     first substring starting offset
  2367.             :end1       first substring ending offset + 1
  2368.             :start2     second substring starting offset
  2369.             :end2       second substring ending offset + 1
  2370.             returns     t if predicate is true, nil otherwise
  2371.           Note: case is significant with these comparison functions.
  2372.  
  2373.         (string-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2374.         (string-not-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2375.         (string-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2376.         (string-not-equalp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2377.         (string-not-lessp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2378.         (string-greaterp <str1> <str2> &key :start1 :end1 :start2 :end2)
  2379.             <str1>      the first string to compare
  2380.             <str2>      the second string to compare
  2381.             :start1     first substring starting offset
  2382.             :end1       first substring ending offset + 1
  2383.             :start2     second substring starting offset
  2384.             :end2       second substring ending offset + 1
  2385.             returns     t if predicate is true, nil otherwise
  2386.           Note: case is not significant with these comparison functions.
  2387.  
  2388.  
  2389.  
  2390.  
  2391.  
  2392.  
  2393.  
  2394.  
  2395.  
  2396.  
  2397.  
  2398.  
  2399.  
  2400.  
  2401.  
  2402.  
  2403.  
  2404.  
  2405.  
  2406.  
  2407.  
  2408.  
  2409.  
  2410.  
  2411.  
  2412.  
  2413.  
  2414.  
  2415.  
  2416.  
  2417.  
  2418.  
  2419.  
  2420.  
  2421.         XLISP                 CHARACTER FUNCTIONS                Page 39
  2422.  
  2423.  
  2424.         CHARACTER FUNCTIONS
  2425.  
  2426.         (char <string> <index>)  EXTRACT A CHARACTER FROM A STRING
  2427.             <string>    the string
  2428.             <index>     the string index (zero relative)
  2429.             returns     the ascii code of the character
  2430.  
  2431.         (upper-case-p <chr>)  IS THIS AN UPPER CASE CHARACTER?
  2432.             <chr>       the character
  2433.             returns     true if the character is upper case, nil otherwise
  2434.  
  2435.         (lower-case-p <chr>)  IS THIS A LOWER CASE CHARACTER?
  2436.             <chr>       the character
  2437.             returns     true if the character is lower case, nil otherwise
  2438.  
  2439.         (both-case-p <chr>)  IS THIS AN ALPHABETIC (EITHER CASE) CHARACTER?
  2440.             <chr>       the character
  2441.             returns     true if the character is a>     the filename string or symbol
  2442.             :verbose    the verbose flag (default is t)
  2443.             :print      the print flag (default is nil)
  2444.             returns     the filename
  2445.  
  2446.         (save <fname>) SAVE WORKSPACE TO A FILE
  2447.             <fname>     the filename string or symbol
  2448.             returns     t if workspace was written, nil otherwise
  2449.  
  2450.         (restore <fname>) RESTORE WORKSPACE FROM A FILE
  2451.             <fname>     the filename string or symbol
  2452.             returns     nil on failure, otherwise never returns
  2453.  
  2454.         (dribble [<fname>])  CREATE A FILE WITH A TRANSCRIPT OF A SESSION
  2455.             <fname>     file name string or symbol
  2456.                         (if missing, close current transcript)
  2457.             returns     t if the transcript is opened, nil if it is closed
  2458.  
  2459.         (gc)  FORCE GARBAGE COLLECTION
  2460.             returns     nil
  2461.  
  2462.         (expand <num>)  EXPAND MEMORY BY ADDING SEGMENTS
  2463.             <num>       the number of segments to add
  2464.             returns     the number of segments added
  2465.  
  2466.         (alloc <num>)  CHANGE NUMBER OF NODES TO ALLOCATE IN EACH SEGMENT
  2467.             <num>       the number of nodes to allocate
  2468.             returns     the old number of nodes to allocate
  2469.  
  2470.         (room)  SHOW MEMORY ALLOCATION STATISTICS
  2471.             returns     nil
  2472.  
  2473.         (type-of <expr>)  RETURNS THE TYPE OF THE EXPRESSION
  2474.             <expr>      the expression to return the type of
  2475.             returns     nil if the value is nil otherwise one of the symbols:
  2476.                           SYMBOL          for symbols
  2477.                           OBJECT          for objects
  2478.                           CONS            for conses
  2479.                           SUBR            for built-in functions
  2480.                           FSUBR           for special forms
  2481.                           CLOSURE         for defined functions
  2482.                           STRING          for strings
  2483.                           FIXNUM          for integers
  2484.                           FLONUM          for floating point numbers
  2485.                           CHARACTER       for characters
  2486.                           FILE-STREAM     for file pointers
  2487.                           UNNAMED-STREAM  for unnamed streams
  2488.                           ARRAY           for arrays
  2489.  
  2490.  
  2491.  
  2492.  
  2493.  
  2494.  
  2495.  
  2496.  
  2497.  
  2498.  
  2499.  
  2500.  
  2501.         XLISP                   SYSTEM FUNCTIONS                 Page 46
  2502.  
  2503.  
  2504.         (peek <addrs>)  PEEK AT A LOCATION IN MEMORY
  2505.             <addrs>     the address to peek at (integer)
  2506.             returns     the value at the specified address (integer)
  2507.  
  2508.         (poke <addrs> <value>)  POKE A VALUE INTO MEMORY
  2509.             <addrs>     the address to poke (integer)
  2510.             <value>     the value to poke into the address (integer)
  2511.             returns     the value
  2512.  
  2513.         (address-of <expr>)  GET THE ADDRESS OF AN XLISP NODE
  2514.             <expr>      the node
  2515.             returns     the address of the node (integer)
  2516.  
  2517.         (exit)  EXIT XLISP
  2518.             returns     never returns
  2519.  
  2520.  
  2521.  
  2522.  
  2523.  
  2524.  
  2525.  
  2526.  
  2527.  
  2528.  
  2529.  
  2530.  
  2531.  
  2532.  
  2533.  
  2534.  
  2535.  
  2536.  
  2537.  
  2538.  
  2539.  
  2540.  
  2541.  
  2542.  
  2543.  
  2544.  
  2545.  
  2546.  
  2547.  
  2548.  
  2549.  
  2550.  
  2551.  
  2552.  
  2553.  
  2554.  
  2555.  
  2556.  
  2557.  
  2558.  
  2559.  
  2560.  
  2561.  
  2562.  
  2563.  
  2564.  
  2565.  
  2566.  
  2567.         XLISP                       EXAMPLES                     Page 47
  2568.  
  2569.  
  2570.         FILE I/O FUNCTIONS
  2571.  
  2572.         Input from a File
  2573.  
  2574.         To open a file for input, use the OPEN function with the keyword
  2575.         argument :DIRECTION set to :INPUT.  To open a file for output,
  2576.         use the OPEN function with the keyword argument :DIRECTION set
  2577.         to :OUTPUT.  The OPEN function takes a single required argument
  2578.         which is the name of the file to be opened.  This name can be in
  2579.         the form of a string or a symbol.  The OPEN function returns an
  2580.         object of type FILE-STREAM if it succeeds in opening the
  2581.         specified file.  It returns the value NIL if it fails.  In order
  2582.         to manipulate the file, it is necessary to save the value
  2583.         returned by the OPEN function.  This is usually done by
  2584.         assigning it to a variable with the SETQ special form or by
  2585.         binding it using LET or LET*.  Here is an example:
  2586.  
  2587.             (setq fp (open "init.lsp" :direction :input))
  2588.  
  2589.         Evaluating this expression will result in the file "init.lsp"
  2590.         being opened.  The file object that will be returned by the OPEN
  2591.         function will be assigned to the variable "fp".
  2592.  
  2593.         It is now possible to use the file for input.  To read an
  2594.         expression from the file, just supply the value of the "fp"
  2595.         variable as the optional "stream" argument to READ.
  2596.  
  2597.             (read fp)
  2598.  
  2599.         Evaluating this expression will result in reading the first
  2600.         expression from the file "init.lsp".  The expression will be
  2601.         returned as the result of the READ function.  More expressions
  2602.         can be read from the file using further calls to the READ
  2603.         function.  When there are no more expressions to read, the READ
  2604.         function will return NIL (or whatever value was supplied as the
  2605.         second argument to READ).
  2606.  
  2607.         Once you are done reading from the file, you should close it.
  2608.         To close the file, use the following expression:
  2609.  
  2610.             (close fp)
  2611.  
  2612.         Evaluating this expression will cause the file to be closed.
  2613.  
  2614.  
  2615.  
  2616.  
  2617.  
  2618.  
  2619.  
  2620.  
  2621.  
  2622.  
  2623.  
  2624.  
  2625.  
  2626.  
  2627.  
  2628.  
  2629.  
  2630.  
  2631.  
  2632.  
  2633.         XLISP                       EXAMPLES                     Page 48
  2634.  
  2635.  
  2636.         Output to a File
  2637.  
  2638.         Writing to a file is pretty much the same as reading from one.
  2639.         You need to open the file first.  This time you should use the
  2640.         OPEN function to indicate that you will do output to the file.
  2641.         For example:
  2642.  
  2643.             (setq fp (open "test.dat" :direction :output))
  2644.  
  2645.         Evaluating this expression will open the file "test.dat" for
  2646.         output.  If the file already exists, its current contents will
  2647.         be discarded.  If it doesn't already exist, it will be created.
  2648.         In any case, a FILE-STREAM object will be returned by the OPEN
  2649.         function.  This file object will be assigned to the "fp"
  2650.         variable.
  2651.  
  2652.         It is now possible to write to this file by supplying the value
  2653.         of the "fp" variable as the optional "stream" parameter in the
  2654.         PRINT function.
  2655.  
  2656.             (print "Hello there" fp)
  2657.  
  2658.         Evaluating this expression will result in the string "Hello
  2659.         there" being written to the file "test.dat".  More data can be
  2660.         written to the file using the same technique.
  2661.  
  2662.         Once you are done writing to the file, you should close it.
  2663.         Closing an output file is just like closing an input file.
  2664.  
  2665.             (close fp)
  2666.  
  2667.         Evaluating this expression will close the output file and make
  2668.         it permanent.
  2669.  
  2670.  
  2671.  
  2672.  
  2673.  
  2674.  
  2675.  
  2676.  
  2677.  
  2678.  
  2679.  
  2680.  
  2681.  
  2682.  
  2683.  
  2684.  
  2685.  
  2686.  
  2687.  
  2688.  
  2689.  
  2690.  
  2691.  
  2692.  
  2693.  
  2694.  
  2695.  
  2696.  
  2697.  
  2698.  
  2699.         XLISP                       EXAMPLES                     Page 49
  2700.  
  2701.  
  2702.         A Slightly More Complicated File Example
  2703.  
  2704.         This example shows how to open a file, read each Lisp expression
  2705.         from the file and print it.  It demonstrates the use of files
  2706.         and the use of the optional "stream" argument to the READ
  2707.         function.
  2708.  
  2709.             (do* ((fp (open "test.dat" :direction :input))
  2710.                   (ex (read fp) (read fp)))
  2711.                  ((null ex) nil)
  2712.               (print ex))
  2713.  
  2714.  
  2715.  
  2716.  
  2717.  
  2718.  
  2719.  
  2720.  
  2721.  
  2722.  
  2723.  
  2724.  
  2725.  
  2726.  
  2727.  
  2728.  
  2729.  
  2730.  
  2731.  
  2732.  
  2733.  
  2734.  
  2735.  
  2736.  
  2737.  
  2738.  
  2739.  
  2740.  
  2741.  
  2742.  
  2743.  
  2744.  
  2745.  
  2746.  
  2747.  
  2748.  
  2749.  
  2750.  
  2751.  
  2752.  
  2753.  
  2754.  
  2755.  
  2756.  
  2757.  
  2758.  
  2759.  
  2760.  
  2761.  
  2762.                SYSTEM FUNCTIONS                 Page 46
  2763.  
  2764.  
  2765.         (peek <addrs>)  PEEK AT A LOCATION IN MEMORY
  2766.