/[cvsroot]/skandha4/info/slisp-2
ViewVC logotype

Contents of /skandha4/info/slisp-2

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue May 25 09:39:19 1999 UTC (21 years, 5 months ago) by jsp
Branch: biostr, MAIN
CVS Tags: skandha4, skandha4_1_6, dsg_1_0, HEAD
Branch point for: skandha4_pub, autoconf
Changes since 1.1: +0 -0 lines
ANSI C version of Skandha4


1 This is Info file slisp, produced by Makeinfo version 1.68 from the
2 input file slisp.texi.
3
4 This file documents slisp, (skandha-lisp), an extendable xlisp.
5
6 Copyright @copyright 1994 University of Washington Digital Anatomist
7 Program by Jeff Prothero (jsp@biostr.washington.edu) and Jim Brinkley
8 See slisp/SLISPCOPYING for details
9
10 
11 File: slisp, Node: Break Command Loop, Next: Data Types, Prev: Xlisp Command Loop, Up: Xlisp Tutorial
12
13 Break Command Loop
14 ==================
15
16 When XLISP encounters an error while evaluating an expression, it
17 attempts to handle the error in the following way:
18
19 If the symbol '*breakenable*' is true, the message corresponding to
20 the error is printed. If the error is correctable, the correction
21 message is printed.
22
23 If the symbol '*tracenable*' is true, a trace back is printed. The
24 number of entries printed depends on the value of the symbol
25 '*tracelimit*'. If this symbol is set to something other than a number,
26 the entire trace back stack is printed.
27
28 XLISP then enters a read/eval/print loop to allow the user to examine
29 the state of the interpreter in the context of the error. This loop
30 differs from the normal top-level read/eval/print loop in that if the
31 user invokes the function 'continue', XLISP will continue from a
32 correctable error. If the user invokes the function 'clean-up', XLISP
33 will abort the break loop and return to the top level or the next lower
34 numbered break loop. When in a break loop, XLISP prefixes the break
35 level to the normal prompt.
36
37 If the symbol '*breakenable*' is nil, XLISP looks for a surrounding
38 errset function. If one is found, XLISP examines the value of the print
39 flag. If this flag is true, the error message is printed. In any case,
40 XLISP causes the errset function call to return nil.
41
42 If there is no surrounding errset function, XLISP prints the error
43 message and returns to the top level.
44
45 
46 File: slisp, Node: Data Types, Next: The Evaluator, Prev: Break Command Loop, Up: Xlisp Tutorial
47
48 Data Types
49 ==========
50
51 There are several different data types available to XLISP
52 programmers.
53 * lists
54
55 * symbols
56
57 * strings
58
59 * integers
60
61 * characters
62
63 * floats
64
65 * objects
66
67 * arrays
68
69 * streams
70
71 * subrs (built-in functions)
72
73 * fsubrs (special forms)
74
75 * closures (user defined functions)
76
77 
78 File: slisp, Node: The Evaluator, Next: Lexical Conventions, Prev: Data Types, Up: Xlisp Tutorial
79
80 The Evaluator
81 =============
82
83 The process of evaluation in XLISP:
84
85 Strings, integers, characters, floats, objects, arrays, streams,
86 subrs, fsubrs and closures evaluate to themselves.
87
88 Symbols act as variables and are evaluated by retrieving the value
89 associated with their current binding.
90
91 Lists are evaluated by examining the first element of the list and
92 then taking one of the following actions:
93 If it is a symbol, the functional binding of the symbol is
94 retrieved.
95
96 If it is a lambda expression, a closure is constructed for the
97 function described by the lambda expression.
98
99 If it is a subr, fsubr or closure, it stands for itself.
100
101 Any other value is an error.
102
103 Then, the value produced by the previous step is examined:
104 If it is a subr or closure, the remaining list elements are
105 evaluated and the subr or closure is called with these evaluated
106 expressions as arguments.
107
108 If it is an fsubr, the fsubr is called using the remaining list
109 elements as arguments (unevaluated).
110
111 If it is a macro, the macro is expanded using the remaining list
112 elements as arguments (unevaluated). The macro expansion is then
113 evaluated in place of the original macro call.
114
115 
116 File: slisp, Node: Lexical Conventions, Next: Readtables, Prev: The Evaluator, Up: Xlisp Tutorial
117
118 Lexical Conventions
119 ===================
120
121 The following conventions must be followed when entering XLISP
122 programs:
123
124 Comments in XLISP code begin with a semi-colon character and
125 continue to the end of the line.
126
127 Symbol names in XLISP can consist of any sequence of non-blank
128 printable characters except the following:
129
130 ( ) ' ` , " ;
131
132 Uppercase and lowercase characters are not distinguished within
133 symbol names. All lowercase characters are mapped to uppercase on
134 input.
135
136 Integer literals consist of a sequence of digits optionally beginning
137 with a '+' or '-'. The range of values an integer can represent is
138 limited by the size of a C 'long' on the machine on which XLISP is
139 running.
140
141 Floating point literals consist of a sequence of digits optionally
142 beginning with a '+' or '-' and including an embedded decimal point.
143 The range of values a floating point number can represent is limited by
144 the size of a C 'float' ('double' on machines with 32 bit addresses) on
145 the machine on which XLISP is running.
146
147 Literal strings are sequences of characters surrounded by double
148 quotes. Within quoted strings the '\' character is used to allow
149 non-printable characters to be included. The codes recognized are:
150
151 \\ means the character '\'
152 \n means newline
153 \t means tab
154 \r means return
155 \f means form feed
156 \nnn means the character whose octal code is nnn
157
158 
159 File: slisp, Node: Readtables, Next: Lambda Lists, Prev: Lexical Conventions, Up: Xlisp Tutorial
160
161 Readtables
162 ==========
163
164 The behaviour of the reader is controlled by a data structure called
165 a "readtable". The reader uses the symbol *READTABLE* to locate the
166 current readtable. This table controls the interpretation of input
167 characters. It is an array with 128 entries, one for each of the ASCII
168 character codes. Each entry contains one of the following things:
169
170 NIL Indicating an invalid character
171 :CONSTITUENT Indicating a symbol constituent
172 :WHITE-SPACE Indicating a whitespace character
173 (:TMACRO . fun) Terminating readmacro
174 (:NMACRO . fun) Non-terminating readmacro
175 :SESCAPE Single escape character ('\')
176 :MESCAPE Multiple escape character ('|')
177
178 In the case of :TMACRO and :NMACRO, the "fun" component is a
179 function. This can either be a built-in readmacro function or a lambda
180 expression. The function should take two parameters. The first is the
181 input stream and the second is the character that caused the invocation
182 of the readmacro. The readmacro function should return NIL to indicate
183 that the character should be treated as white space or a value consed
184 with NIL to indicate that the readmacro should be treated as an
185 occurance of the specified value. Of course, the readmacro code is
186 free to read additional characters from the input stream.
187
188 XLISP defines several useful read macros:
189
190 '<expr> == (quote <expr>)
191 #'<expr> == (function <expr>)
192 #(<expr>...) == an array of the specified expressions
193 #x<hdigits> == a hexadecimal number (0-9,A-F)
194 #o<odigits> == an octal number (0-7)
195 #b<bdigits> == a binary number (0-1)
196 #\<char> == the ASCII code of the character
197 #| ... |# == a comment
198 #:<symbol> == an uninterned symbol
199 `<expr> == (backquote <expr>)
200 ,<expr> == (comma <expr>)
201 ,@<expr> == (comma-at <expr>)
202
203 
204 File: slisp, Node: Lambda Lists, Next: Objects, Prev: Readtables, Up: Xlisp Tutorial
205
206 Lambda Lists
207 ============
208
209 There are several forms in XLISP that require that a "lambda list" be
210 specified. A lambda list is a definition of the arguments accepted by a
211 function. There are four different types of arguments.
212
213 The lambda list starts with required arguments. Required arguments
214 must be specified in every call to the function.
215
216 The required arguments are followed by the &optional arguments.
217 Optional arguments may be provided or omitted in a call. An
218 initialization expression may be specified to provide a default value
219 for an &optional argument if it is omitted from a call. If no
220 initialization expression is specified, an omitted argument is
221 initialized to NIL. It is also possible to provide the name of a
222 'supplied-p' variable that can be used to determine if a call provided a
223 value for the argument or if the initialization expression was used. If
224 specified, the supplied- p variable will be bound to T if a value was
225 specified in the call and NIL if the default value was used.
226
227 The &optional arguments are followed by the &rest argument. The
228 &rest argument gets bound to the remainder of the argument list after
229 the required and &optional arguments have been removed.
230
231 The &rest argument is followed by the &key arguments. When a keyword
232 argument is passed to a function, a pair of values appears in the
233 argument list. The first expression in the pair should evaluate to a
234 keyword symbol (a symbol that begins with a ':'). The value of the
235 second expression is the value of the keyword argument. Like &optional
236 arguments, &key arguments can have initialization expressions and
237 supplied-p variables. In addition, it is possible to specify the
238 keyword to be used in a function call. If no keyword is specified, the
239 keyword obtained by adding a ':' to the beginning of the keyword
240 argument symbol is used. In other words, if the keyword argument symbol
241 is 'foo', the keyword will be ':foo'.
242
243 The &key arguments are followed by the &aux variables. These are
244 local variables that are bound during the evaluation of the function
245 body. It is possible to have initialization expressions for the &aux
246 variables.
247
248 Here is the complete syntax for lambda lists:
249
250 (<rarg>...
251 [&optional [<oarg> | (<oarg> [<init> [<svar>]])]...]
252 [&rest <rarg>]
253 [&key
254 [<karg> | ([<karg> | (<key> <karg>)] [<init> [<svar>]])]...
255 &allow-other-keys]
256 [&aux
257 [<aux> | (<aux> [<init>])]...])
258
259 where:
260
261 <rarg> is a required argument symbol
262 <oarg> is an &optional argument symbol
263 <rarg> is the &rest argument symbol
264 <karg> is a &key argument symbol
265 <key> is a keyword symbol
266 <aux> is an auxiliary variable symbol
267 <init> is an initialization expression
268 <svar> is a supplied-p variable symbol
269
270 
271 File: slisp, Node: Objects, Next: Class Object, Prev: Lambda Lists, Up: Xlisp Tutorial
272
273 Objects
274 =======
275
276 Definitions:
277
278 * selector - a symbol used to select an appropriate method
279
280 * message - a selector and a list of actual arguments
281
282 * method - the code that implements a message
283
284 Since XLISP was created to provide a simple basis for experimenting
285 with object-oriented programming, one of the primitive data types
286 included is 'object'. In XLISP, an object consists of a data structure
287 containing a pointer to the object's class as well as an array
288 containing the values of the object's instance variables.
289
290 Officially, there is no way to see inside an object (look at the
291 values of its instance variables). The only way to communicate with an
292 object is by sending it a message.
293
294 You can send a message to an object using the 'send' function. This
295 function takes the object as its first argument, the message selector as
296 its second argument (which must be a symbol) and the message arguments
297 as its remaining arguments.
298
299 The 'send' function determines the class of the receiving object and
300 attempts to find a method corresponding to the message selector in the
301 set of messages defined for that class. If the message is not found in
302 the object's class and the class has a super-class, the search continues
303 by looking at the messages defined for the super-class. This process
304 continues from one super-class to the next until a method for the
305 message is found. If no method is found, an error occurs.
306
307 A message can also be sent from the body of a method by using the
308 current object, but the method lookup starts with the object's
309 superclass rather than its class. This allows a subclass to invoke a
310 standard method in its parent class even though it overrides that method
311 with its own specialized version.
312
313 When a method is found, the evaluator binds the receiving object to
314 the symbol 'self' and evaluates the method using the remaining elements
315 of the original list as arguments to the method. These arguments are
316 always evaluated prior to being bound to their corresponding formal
317 arguments. The result of evaluating the method becomes the result of
318 the expression.
319
320 
321 File: slisp, Node: Class Object, Next: Class Class, Prev: Objects, Up: Xlisp Tutorial
322
323 Class Object
324 ============
325
326 Object THE TOP OF THE CLASS HIERARCHY
327
328 Messages:
329
330 :show SHOW AN OBJECT'S INSTANCE VARIABLES
331 returns the object
332
333 :class RETURN THE CLASS OF AN OBJECT
334 returns the class of the object
335
336 :isnew THE DEFAULT OBJECT INITIALIZATION ROUTINE
337 returns the object
338
339 
340 File: slisp, Node: Class Class, Next: Symbols, Prev: Class Object, Up: Xlisp Tutorial
341
342 Class Class
343 ===========
344
345 Class THE CLASS OF ALL OBJECT CLASSES (including itself)
346
347 Messages:
348
349 :new CREATE A NEW INSTANCE OF A CLASS
350 returns the new class object
351
352 :isnew <ivars> [<cvars> [<super>]] INITIALIZE A NEW CLASS
353 <ivars> the list of instance variable symbols
354 <cvars> the list of class variable symbols
355 <super> the superclass (default is Object)
356 returns the new class object
357
358 :answer <msg> <fargs> <code> ADD A MESSAGE TO A CLASS
359 <msg> the message symbol
360 <fargs> the formal argument list (lambda list)
361 <code> a list of executable expressions
362 returns the object
363
364 When a new instance of a class is created by sending the message
365 ':new' to an existing class, the message ':isnew' followed by whatever
366 parameters were passed to the ':new' message is sent to the newly
367 created object.
368
369 When a new class is created by sending the ':new' message to the
370 object 'Class', an optional parameter may be specified indicating the
371 superclass of the new class. If this parameter is omitted, the new
372 class will be a subclass of 'Object'. A class inherits all instance
373 variables, class variables, and methods from its super-class.
374
375 
376 File: slisp, Node: Symbols, Next: Evaluation Functions, Prev: Class Class, Up: Xlisp Tutorial
377
378 Symbols
379 =======
380
381 SYMBOLS
382 * self - the current object (within a method context)
383
384 * *obarray* - the object hash table
385
386 * *standard-input* - the standard input stream
387
388 * *standard-output* - the standard output stream
389
390 * *error-output* - the error output stream
391
392 * *trace-output* - the trace output stream
393
394 * *debug-io* - the debug i/o stream
395
396 * *breakenable* - flag controlling entering break loop on errors
397
398 * *tracelist* - list of names of functions to trace
399
400 * *tracenable* - enable trace back printout on errors
401
402 * *tracelimit* - number of levels of trace back information
403
404 * *evalhook* - user substitute for the evaluator function
405
406 * *applyhook* - (not yet implemented)
407
408 * *readtable* - the current readtable
409
410 * *unbound* - indicator for unbound symbols
411
412 * *gc-flag* - controls the printing of gc messages
413
414 * *gc-hook* - function to call after garbage collection
415
416 * *integer-format* - format for printing integers ("%d" or "%ld")
417
418 * *float-format* - format for printing floats ("%g")
419
420 * *print-case* - symbol output case (:upcase or :downcase)
421
422 There are several symbols maintained by the read/eval/print loop.
423 The symbols '+', '++', and '+++' are bound to the most recent three
424 input expressions. The symbols '*', '**' and '***' are bound to the
425 most recent three results. The symbol '-' is bound to the expression
426 currently being evaluated. It becomes the value of '+' at the end of
427 the evaluation.
428
429 
430 File: slisp, Node: Evaluation Functions, Next: Symbol Functions, Prev: Symbols, Up: Xlisp Tutorial
431
432 Evaluation Functions
433 ====================
434
435 (eval <expr>) EVALUATE AN XLISP EXPRESSION
436 <expr> the expression to be evaluated
437 returns the result of evaluating the expression
438
439 (apply <fun> <args>) APPLY A FUNCTION TO A LIST OF ARGUMENTS
440 <fun> the function to apply (or function symbol)
441 <args> the argument list
442 returns the result of applying the function to the arguments
443
444 (funcall <fun> <arg>...) CALL A FUNCTION WITH ARGUMENTS
445 <fun> the function to call (or function symbol)
446 <arg> arguments to pass to the function
447 returns the result of calling the function with the arguments
448
449 (quote <expr>) RETURN AN EXPRESSION UNEVALUATED
450 <expr> the expression to be quoted (quoted)
451 returns <expr> unevaluated
452
453 (function <expr>) GET THE FUNCTIONAL INTERPRETATION
454 <expr> the symbol or lambda expression (quoted)
455 returns the functional interpretation
456
457 (backquote <expr>) FILL IN A TEMPLATE
458 <expr> the template
459 returns a copy of the template with comma and comma-at
460 expressions expanded
461
462 (lambda <args> <expr>...) MAKE A FUNCTION CLOSURE
463 <args> formal argument list (lambda list) (quoted)
464 <expr> expressions of the function body
465 returns the function closure
466
467 (get-lambda-expression <closure>) GET THE LAMBDA EXPRESSION
468 <closure> the closure
469 returns the original lambda expression
470
471 (macroexpand <form>) RECURSIVELY EXPAND MACRO CALLS
472 <form> the form to expand
473 returns the macro expansion
474
475 (macroexpand-1 <form>) EXPAND A MACRO CALL
476 <form> the macro call form
477 returns the macro expansion
478
479 
480 File: slisp, Node: Symbol Functions, Next: Property List Functions, Prev: Evaluation Functions, Up: Xlisp Tutorial
481
482 Symbol Functions
483 ================
484
485 (set <sym> <expr>) SET THE VALUE OF A SYMBOL
486 <sym> the symbol being set
487 <expr> the new value
488 returns the new value
489
490 (setq [<sym> <expr>]...) SET THE VALUE OF A SYMBOL
491 <sym> the symbol being set (quoted)
492 <expr> the new value
493 returns the new value
494
495 (psetq [<sym> <expr>]...) PARALLEL VERSION OF SETQ
496 <sym> the symbol being set (quoted)
497 <expr> the new value
498 returns the new value
499
500 (setf [<place> <expr>]...) SET THE VALUE OF A FIELD
501 <place> the field specifier (quoted):
502 <sym> set value of a symbol
503 (car <expr>) set car of a cons node
504 (cdr <expr>) set cdr of a cons node
505 (nth <n> <expr>) set nth car of a list
506 (aref <expr> <n>) set nth element of an array
507 (get <sym> <prop>) set value of a property
508 (symbol-value <sym>) set value of a symbol
509 (symbol-function <sym>) set functional value of a symbol
510 (symbol-plist <sym>) set property list of a symbol
511 <value> the new value
512 returns the new value
513
514 (defun <sym> <fargs> <expr>...) DEFINE A FUNCTION
515 (defmacro <sym> <fargs> <expr>...) DEFINE A MACRO
516 <sym> symbol being defined (quoted)
517 <fargs> formal argument list (lambda list) (quoted)
518 <expr> expressions constituting the body of the
519 function (quoted)
520 returns the function symbol
521
522 (gensym [<tag>]) GENERATE A SYMBOL
523 <tag> string or number
524 returns the new symbol
525
526 (intern <pname>) MAKE AN INTERNED SYMBOL
527 <pname> the symbol's print name string
528 returns the new symbol
529
530 (make-symbol <pname>) MAKE AN UNINTERNED SYMBOL
531 <pname> the symbol's print name string
532 returns the new symbol
533
534 (symbol-name <sym>) GET THE PRINT NAME OF A SYMBOL
535 <sym> the symbol
536 returns the symbol's print name
537
538 (symbol-value <sym>) GET THE VALUE OF A SYMBOL
539 <sym> the symbol
540 returns the symbol's value
541
542 (symbol-function <sym>) GET THE FUNCTIONAL VALUE OF A SYMBOL
543 <sym> the symbol
544 returns the symbol's functional value
545
546 (symbol-plist <sym>) GET THE PROPERTY LIST OF A SYMBOL
547 <sym> the symbol
548 returns the symbol's property list
549
550 (hash <sym> <n>) COMPUTE THE HASH INDEX FOR A SYMBOL
551 <sym> the symbol or string
552 <n> the table size (integer)
553 returns the hash index (integer)
554
555 
556 File: slisp, Node: Property List Functions, Next: Array Functions, Prev: Symbol Functions, Up: Xlisp Tutorial
557
558 Property List Functions
559 =======================
560
561 (get <sym> <prop>) GET THE VALUE OF A PROPERTY
562 <sym> the symbol
563 <prop> the property symbol
564 returns the property value or nil
565
566 (putprop <sym> <val> <prop>) PUT A PROPERTY ONTO A PROPERTY LIST
567 <sym> the symbol
568 <val> the property value
569 <prop> the property symbol
570 returns the property value
571
572 (remprop <sym> <prop>) REMOVE A PROPERTY
573 <sym> the symbol
574 <prop> the property symbol
575 returns nil
576
577 
578 File: slisp, Node: Array Functions, Next: List Functions, Prev: Property List Functions, Up: Xlisp Tutorial
579
580 Array Functions
581 ===============
582
583 (aref <array> <n>) GET THE NTH ELEMENT OF AN ARRAY
584 <array> the array
585 <n> the array index (integer)
586 returns the value of the array element
587
588 (make-array <size>) MAKE A NEW ARRAY
589 <size> the size of the new array (integer)
590 returns the new array
591
592 (vector <expr>...) MAKE AN INITIALIZED VECTOR
593 <expr> the vector elements
594 returns the new vector
595
596 (copy-array <src> <dest> [<dest-pos>]) COPY INTO A PREALLOC'd ARRAY
597 <src> the array to copy from
598 <dest> the array to copy to, preallocated by MAKE-ARRAY
599 <dest-pos> the integer offset in <dest> for beginning the copy
600 If <dest-pos> is omitted, this defaults to 0.
601 returns <dest>.
602
603 (array-insert-pos <array> <pos> <elt>) INSERT A NEW ELEMENT IN ARRAY
604 <array> an array into which we want to insert a new element
605 <pos> the integer index in <array> for inserted element;
606 <pos> < 0 will cause the new element to be appended.
607 <elt> any lisp value
608 returns a new array that is one element longer than <array>;
609
610 (array-delete-pos <array> <pos>) DELETE AN ELEMENT FROM AN ARRAY
611 <array> an array into which we want to delete an element
612 <pos> the integer index for the element to delete in <array>;
613 <pos> < 0 will delete the last element of the array.
614 returns a new array that is one element shorter than <array>
615
616 NOTE: copy-array, array-insert-pos, and array-delete-pos are new
617 primitives added to XLISP by Niels Mayer for use with WINTERP.
618
619 
620 File: slisp, Node: List Functions, Next: Destructive List Functions, Prev: Array Functions, Up: Xlisp Tutorial
621
622 List Functions
623 ==============
624
625 (car <expr>) RETURN THE CAR OF A LIST NODE
626 <expr> the list node
627 returns the car of the list node
628
629 (cdr <expr>) RETURN THE CDR OF A LIST NODE
630 <expr> the list node
631 returns the cdr of the list node
632
633 (cxxr <expr>) ALL CxxR COMBINATIONS
634 (cxxxr <expr>) ALL CxxxR COMBINATIONS
635 (cxxxxr <expr>) ALL CxxxxR COMBINATIONS
636
637 (first <expr>) A SYNONYM FOR CAR
638 (second <expr>) A SYNONYM FOR CADR
639 (third <expr>) A SYNONYM FOR CADDR
640 (fourth <expr>) A SYNONYM FOR CADDDR
641 (rest <expr>) A SYNONYM FOR CDR
642
643 (cons <expr1> <expr2>) CONSTRUCT A NEW LIST NODE
644 <expr1> the car of the new list node
645 <expr2> the cdr of the new list node
646 returns the new list node
647
648 (list <expr>...) CREATE A LIST OF VALUES
649 <expr> expressions to be combined into a list
650 returns the new list
651
652 (append <expr>...) APPEND LISTS
653 <expr> lists whose elements are to be appended
654 returns the new list
655
656 (reverse <expr>) REVERSE A LIST
657 <expr> the list to reverse
658 returns a new list in the reverse order
659
660 (last <list>) RETURN THE LAST LIST NODE OF A LIST
661 <list> the list
662 returns the last list node in the list
663
664 (member <expr> <list> &key :test :test-not) FIND AN EXPRESSION IN A LIST
665 <expr> the expression to find
666 <list> the list to search
667 :test the test function (defaults to eql)
668 :test-not the test function (sense inverted)
669 returns the remainder of the list starting with the expression
670
671 (assoc <expr> <alist> &key :test :test-not) FIND AN EXPRESSION IN AN A-LIST
672 <expr> the expression to find
673 <alist> the association list
674 :test the test function (defaults to eql)
675 :test-not the test function (sense inverted)
676 returns the alist entry or nil
677
678 (remove <expr> <list> &key :test :test-not) REMOVE ELEMENTS FROM A LIST
679 <expr> the element to remove
680 <list> the list
681 :test the test function (defaults to eql)
682 :test-not the test function (sense inverted)
683 returns copy of list with matching expressions removed
684
685 (remove-if <test> <list>) REMOVE ELEMENTS THAT PASS TEST
686 <test> the test predicate
687 <list> the list
688 returns copy of list with matching elements removed
689
690 (remove-if-not <test> <list>) REMOVE ELEMENTS THAT FAIL TEST
691 <test> the test predicate
692 <list> the list
693 returns copy of list with non-matching elements removed
694
695 (length <expr>) FIND THE LENGTH OF A LIST, VECTOR OR STRING
696 <expr> the list, vector or string
697 returns the length of the list, vector or string
698
699 (nth <n> <list>) RETURN THE NTH ELEMENT OF A LIST
700 <n> the number of the element to return (zero origin)
701 <list> the list
702 returns the nth element or nil if the list isn't that long
703
704 (nthcdr <n> <list>) RETURN THE NTH CDR OF A LIST
705 <n> the number of the element to return (zero origin)
706 <list> the list
707 returns the nth cdr or nil if the list isn't that long
708
709 (mapc <fcn> <list1> <list>...) APPLY FUNCTION TO SUCCESSIVE CARS
710 <fcn> the function or function name
711 <listn> a list for each argument of the function
712 returns the first list of arguments
713
714 (mapcar <fcn> <list1> <list>...) APPLY FUNCTION TO SUCCESSIVE CARS
715 <fcn> the function or function name
716 <listn> a list for each argument of the function
717 returns a list of the values returned
718
719 (mapl <fcn> <list1> <list>...) APPLY FUNCTION TO SUCCESSIVE CDRS
720 <fcn> the function or function name
721 <listn> a list for each argument of the function
722 returns the first list of arguments
723
724 (maplist <fcn> <list1> <list>...) APPLY FUNCTION TO SUCCESSIVE CDRS
725 <fcn> the function or function name
726 <listn> a list for each argument of the function
727 returns a list of the values returned
728
729 (subst <to> <from> <expr> &key :test :test-not) SUBSTITUTE EXPRESSIONS
730 <to> the new expression
731 <from> the old expression
732 <expr> the expression in which to do the substitutions
733 :test the test function (defaults to eql)
734 :test-not the test function (sense inverted)
735 returns the expression with substitutions
736
737 (sublis <alist> <expr> &key :test :test-not) SUBSTITUTE WITH AN A-LIST
738 <alist> the association list
739 <expr> the expression in which to do the substitutions
740 :test the test function (defaults to eql)
741 :test-not the test function (sense inverted)
742 returns the expression with substitutions
743
744 
745 File: slisp, Node: Destructive List Functions, Next: Predicate Functions, Prev: List Functions, Up: Xlisp Tutorial
746
747 Destructive List Functions
748 ==========================
749
750 (rplaca <list> <expr>) REPLACE THE CAR OF A LIST NODE
751 <list> the list node
752 <expr> the new value for the car of the list node
753 returns the list node after updating the car
754
755 (rplacd <list> <expr>) REPLACE THE CDR OF A LIST NODE
756 <list> the list node
757 <expr> the new value for the cdr of the list node
758 returns the list node after updating the cdr
759
760 (nconc <list>...) DESTRUCTIVELY CONCATENATE LISTS
761 <list> lists to concatenate
762 returns the result of concatenating the lists
763
764 (delete <expr> &key :test :test-not) DELETE ELEMENTS FROM A LIST
765 <expr> the element to delete
766 <list> the list
767 :test the test function (defaults to eql)
768 :test-not the test function (sense inverted)
769 returns the list with the matching expressions deleted
770
771 (delete-if <test> <list>) DELETE ELEMENTS THAT PASS TEST
772 <test> the test predicate
773 <list> the list
774 returns the list with matching elements deleted
775
776 (delete-if-not <test> <list>) DELETE ELEMENTS THAT FAIL TEST
777 <test> the test predicate
778 <list> the list
779 returns the list with non-matching elements deleted
780
781 (sort <list> <test>) SORT A LIST
782 <list> the list to sort
783 <test> the comparison function
784 returns the sorted list
785
786 
787 File: slisp, Node: Predicate Functions, Next: Control Constructs, Prev: Destructive List Functions, Up: Xlisp Tutorial
788
789 Predicate Functions
790 ===================
791
792 (atom <expr>) IS THIS AN ATOM?
793 <expr> the expression to check
794 returns t if the value is an atom, nil otherwise
795
796 (symbolp <expr>) IS THIS A SYMBOL?
797 <expr> the expression to check
798 returns t if the expression is a symbol, nil otherwise
799
800 (numberp <expr>) IS THIS A NUMBER?
801 <expr> the expression to check
802 returns t if the expression is a number, nil otherwise
803
804 (null <expr>) IS THIS AN EMPTY LIST?
805 <expr> the list to check
806 returns t if the list is empty, nil otherwise
807
808 (not <expr>) IS THIS FALSE?
809 <expr> the expression to check
810 return t if the value is nil, nil otherwise
811
812 (listp <expr>) IS THIS A LIST?
813 <expr> the expression to check
814 returns t if the value is a cons or nil, nil otherwise
815
816 (endp <list>) IS THIS THE END OF A LIST
817 <list> the list
818 returns t if the value is nil, nil otherwise
819
820 (consp <expr>) IS THIS A NON-EMPTY LIST?
821 <expr> the expression to check
822 returns t if the value is a cons, nil otherwise
823
824 (integerp <expr>) IS THIS AN INTEGER?
825 <expr> the expression to check
826 returns t if the value is an integer, nil otherwise
827
828 (floatp <expr>) IS THIS A FLOAT?
829 <expr> the expression to check
830 returns t if the value is a float, nil otherwise
831
832 (stringp <expr>) IS THIS A STRING?
833 <expr> the expression to check
834 returns t if the value is a string, nil otherwise
835
836 (characterp <expr>) IS THIS A CHARACTER?
837 <expr> the expression to check
838 returns t if the value is a character, nil otherwise
839
840 (arrayp <expr>) IS THIS AN ARRAY?
841 <expr> the expression to check
842 returns t if the value is an array, nil otherwise
843
844 (streamp <expr>) IS THIS A STREAM?
845 <expr> the expression to check
846 returns t if the value is a stream, nil otherwise
847
848 (objectp <expr>) IS THIS AN OBJECT?
849 <expr> the expression to check
850 returns t if the value is an object, nil otherwise
851
852 #ifdef WINTERP
853 (widgetobjp <expr>) IS THIS A WIDGETOBJ?
854 <expr> the expression to check
855 returns t if the value is an object, nil otherwise
856 #endif
857
858 (boundp <sym>) IS A VALUE BOUND TO THIS SYMBOL?
859 <sym> the symbol
860 returns t if a value is bound to the symbol, nil otherwise
861
862 (fboundp <sym>) IS A FUNCTIONAL VALUE BOUND TO THIS SYMBOL?
863 <sym> the symbol
864 returns t if a functional value is bound to the symbol,
865 nil otherwise
866
867 (minusp <expr>) IS THIS NUMBER NEGATIVE?
868 <expr> the number to test
869 returns t if the number is negative, nil otherwise
870
871 (zerop <expr>) IS THIS NUMBER ZERO?
872 <expr> the number to test
873 returns t if the number is zero, nil otherwise
874
875 (plusp <expr>) IS THIS NUMBER POSITIVE?
876 <expr> the number to test
877 returns t if the number is positive, nil otherwise
878
879 (evenp <expr>) IS THIS INTEGER EVEN?
880 <expr> the integer to test
881 returns t if the integer is even, nil otherwise
882
883 (oddp <expr>) IS THIS INTEGER ODD?
884 <expr> the integer to test
885 returns t if the integer is odd, nil otherwise
886
887 (eq <expr1> <expr2>) ARE THE EXPRESSIONS IDENTICAL?
888 <expr1> the first expression
889 <expr2> the second expression
890 returns t if they are equal, nil otherwise
891
892 (eql <expr1> <expr2>) ARE THE EXPRESSIONS IDENTICAL?
893 (WORKS WITH ALL NUMBERS)
894 <expr1> the first expression
895 <expr2> the second expression
896 returns t if they are equal, nil otherwise
897
898 (equal <expr1> <expr2>) ARE THE EXPRESSIONS EQUAL?
899 <expr1> the first expression
900 <expr2> the second expression
901 returns t if they are equal, nil otherwise
902
903 
904 File: slisp, Node: Control Constructs, Next: Looping Constructs, Prev: Predicate Functions, Up: Xlisp Tutorial
905
906 Control Constructs
907 ==================
908
909 (cond <pair>...) EVALUATE CONDITIONALLY
910 <pair> pair consisting of:
911 (<pred> <expr>...)
912 where
913 <pred> is a predicate expression
914 <expr> evaluated if the predicate
915 is not nil
916 returns the value of the first expression whose predicate
917 is not nil
918
919 (and <expr>...) THE LOGICAL AND OF A LIST OF EXPRESSIONS
920 <expr> the expressions to be ANDed
921 returns nil if any expression evaluates to nil,
922 otherwise the value of the last expression
923 (evaluation of expressions stops after the first
924 expression that evaluates to nil)
925
926 (or <expr>...) THE LOGICAL OR OF A LIST OF EXPRESSIONS
927 <expr> the expressions to be ORed
928 returns nil if all expressions evaluate to nil,
929 otherwise the value of the first non-nil expression
930 (evaluation of expressions stops after the first
931 expression that does not evaluate to nil)
932
933 (if <texpr> <expr1> [<expr2>]) EVALUATE EXPRESSIONS CONDITIONALLY
934 <texpr> the test expression
935 <expr1> the expression to be evaluated if texpr is non-nil
936 <expr2> the expression to be evaluated if texpr is nil
937 returns the value of the selected expression
938
939 (when <texpr> <expr>...) EVALUATE ONLY WHEN A CONDITION IS TRUE
940 <texpr> the test expression
941 <expr> the expression(s) to be evaluted if texpr is non-nil
942 returns the value of the last expression or nil
943
944 (unless <texpr> <expr>...) EVALUATE ONLY WHEN A CONDITION IS FALSE
945 <texpr> the test expression
946 <expr> the expression(s) to be evaluated if texpr is nil
947 returns the value of the last expression or nil
948
949 (case <expr> <case>...) SELECT BY CASE
950 <expr> the selection expression
951 <case> pair consisting of:
952 (<value> <expr>...)
953 where:
954 <value> is a single expression or a list of
955 expressions (unevaluated)
956 <expr> are expressions to execute if the
957 case matches
958 returns the value of the last expression of the matching case
959
960 (let (<binding>...) <expr>...) CREATE LOCAL BINDINGS
961 (let* (<binding>...) <expr>...) LET WITH SEQUENTIAL BINDING
962 <binding> the variable bindings each of which is either:
963 1) a symbol (which is initialized to nil)
964 2) a list whose car is a symbol and whose cadr
965 is an initialization expression
966 <expr> the expressions to be evaluated
967 returns the value of the last expression
968
969 (flet (<binding>...) <expr>...) CREATE LOCAL FUNCTIONS
970 (labels (<binding>...) <expr>...) FLET WITH RECURSIVE FUNCTIONS
971 (macrolet (<binding>...) <expr>...) CREATE LOCAL MACROS
972 <binding> the function bindings each of which is:
973 (<sym> <fargs> <expr>...)
974 where:
975 <sym> the function/macro name
976 <fargs> formal argument list (lambda list)
977 <expr> expressions constituting the body of
978 the function/macro
979 <expr> the expressions to be evaluated
980 returns the value of the last expression
981
982 (catch <sym> <expr>...) EVALUATE EXPRESSIONS AND CATCH THROWS
983 <sym> the catch tag
984 <expr> expressions to evaluate
985 returns the value of the last expression the throw expression
986
987 (throw <sym> [<expr>]) THROW TO A CATCH
988 <sym> the catch tag
989 <expr> the value for the catch to return (defaults to nil)
990 returns never returns
991
992 (unwind-protect <expr> <cexpr>...) PROTECT EVALUATION OF AN EXPRESSION
993 <expr> the expression to protect
994 <cexpr> the cleanup expressions
995 returns the value of the expression
996 Note: unwind-protect guarantees to execute the cleanup expressions
997 even if a non-local exit terminates the evaluation of the
998 protected expression
999
1000 
1001 File: slisp, Node: Looping Constructs, Next: Progs And Blocks, Prev: Control Constructs, Up: Xlisp Tutorial
1002
1003 Looping Constructs
1004 ==================
1005
1006 (loop <expr>...) BASIC LOOPING FORM
1007 <expr> the body of the loop
1008 returns never returns (must use non-local exit)
1009
1010 (do (<binding>...) (<texpr> <rexpr>...) <expr>...)
1011 (do* (<binding>...) (<texpr> <rexpr>...) <expr>...)
1012 <binding> the variable bindings each of which is either:
1013 1) a symbol (which is initialized to nil)
1014 2) a list of the form: (<sym> <init> [<step>])
1015 where:
1016 <sym> is the symbol to bind
1017 <init> is the initial value of the symbol
1018 <step> is a step expression
1019 <texpr> termination expression -- iteration ends when it is non-NIL
1020 <rexpr> result expressions (the default is nil)
1021 <expr> the body of the loop (treated like an implicit prog)
1022 returns the value of the last result expression
1023
1024 (dolist (<sym> <expr> [<rexpr>]) <expr>...) LOOP THROUGH A LIST
1025 <sym> the symbol to bind to each list element
1026 <expr> the list expression
1027 <rexpr> the result expression (the default is nil)
1028 <expr> the body of the loop (treated like an implicit prog)
1029
1030 (dotimes (<sym> <expr> [<rexpr>]) <expr>...) LOOP FROM ZERO TO N-1
1031 <sym> the symbol to bind to each value from 0 to n-1
1032 <expr> the number of times to loop
1033 <rexpr> the result expression (the default is nil)
1034 <expr> the body of the loop (treated like an implicit prog)
1035
1036 
1037 File: slisp, Node: Progs And Blocks, Next: Debugging And Error Handling, Prev: Looping Constructs, Up: Xlisp Tutorial
1038
1039 Progs And Blocks
1040 ================
1041
1042 (prog (<binding>...) <expr>...) THE PROGRAM FEATURE
1043 (prog* (<binding>...) <expr>...) PROG WITH SEQUENTIAL BINDING
1044 <binding> the variable bindings each of which is either:
1045 1) a symbol (which is initialized to nil)
1046 2) a list whose car is a symbol and whose cadr
1047 is an initialization expression
1048 <expr> expressions to evaluate or tags (symbols)
1049 returns nil or the argument passed to the return function
1050
1051 (block <name> <expr>...) NAMED BLOCK
1052 <name> the block name (symbol)
1053 <expr> the block body
1054 returns the value of the last expression
1055
1056 (return [<expr>]) CAUSE A PROG CONSTRUCT TO RETURN A VALUE
1057 <expr> the value (defaults to nil)
1058 returns never returns
1059
1060 (return-from <name> [<value>]) RETURN FROM A NAMED BLOCK
1061 <name> the block name (symbol)
1062 <value> the value to return (defaults to nil)
1063 returns never returns
1064
1065 (tagbody <expr>...) BLOCK WITH LABELS
1066 <expr> expression(s) to evaluate or tags (symbols)
1067 returns nil
1068
1069 (go <sym>) GO TO A TAG WITHIN A TAGBODY OR PROG
1070 <sym> the tag (quoted)
1071 returns never returns
1072
1073 (progv <slist> <vlist> <expr>...) DYNAMICALLY BIND SYMBOLS
1074 <slist> list of symbols
1075 <vlist> list of values to bind to the symbols
1076 <expr> expression(s) to evaluate
1077 returns the value of the last expression
1078
1079 (prog1 <expr1> <expr>...) EXECUTE EXPRESSIONS SEQUENTIALLY
1080 <expr1> the first expression to evaluate
1081 <expr> the remaining expressions to evaluate
1082 returns the value of the first expression
1083
1084 (prog2 <expr1> <expr2> <expr>...) EXECUTE EXPRESSIONS SEQUENTIALLY
1085 <expr1> the first expression to evaluate
1086 <expr2> the second expression to evaluate
1087 <expr> the remaining expressions to evaluate
1088 returns the value of the second expression
1089
1090 (progn <expr>...) EXECUTE EXPRESSIONS SEQUENTIALLY
1091 <expr> the expressions to evaluate
1092 returns the value of the last expression (or nil)
1093
1094 
1095 File: slisp, Node: Debugging And Error Handling, Next: Arithmetic Functions, Prev: Progs And Blocks, Up: Xlisp Tutorial
1096
1097 Debugging And Error Handling
1098 ============================
1099
1100 (trace <sym>) ADD A FUNCTION TO THE TRACE LIST
1101 <sym> the function to add (quoted)
1102 returns the trace list
1103
1104 (untrace <sym>) REMOVE A FUNCTION FROM THE TRACE LIST
1105 <sym> the function to remove (quoted)
1106 returns the trace list
1107
1108 (error <emsg> [<arg>]) SIGNAL A NON-CORRECTABLE ERROR
1109 <emsg> the error message string
1110 <arg> the argument expression (printed after the message)
1111 returns never returns
1112
1113 (cerror <cmsg> <emsg> [<arg>]) SIGNAL A CORRECTABLE ERROR
1114 <cmsg> the continue message string
1115 <emsg> the error message string
1116 <arg> the argument expression (printed after the message)
1117 returns nil when continued from the break loop
1118
1119 (break [<bmsg> [<arg>]]) ENTER A BREAK LOOP
1120 <bmsg> the break message string (defaults to "**BREAK**")
1121 <arg> the argument expression (printed after the message)
1122 returns nil when continued from the break loop
1123
1124 (clean-up) CLEAN-UP AFTER AN ERROR
1125 returns never returns
1126
1127 (top-level) CLEAN-UP AFTER AN ERROR AND RETURN TO THE TOP LEVEL
1128 returns never returns
1129
1130 (continue) CONTINUE FROM A CORRECTABLE ERROR
1131 returns never returns
1132
1133 (errset <expr> [<pflag>]) TRAP ERRORS
1134 <expr> the expression to execute
1135 <pflag> flag to control printing of the error message
1136 returns the value of the last expression consed with nil
1137 or nil on error
1138
1139 (baktrace [<n>]) PRINT N LEVELS OF TRACE BACK INFORMATION
1140 <n> the number of levels (defaults to all levels)
1141 returns nil
1142
1143 (evalhook <expr> <ehook> <ahook> [<env>]) EVALUATE WITH HOOKS
1144 <expr> the expression to evaluate
1145 <ehook> the value for *evalhook*
1146 <ahook> the value for *applyhook*
1147 <env> the environment (default is nil)
1148 returns the result of evaluating the expression
1149
1150 
1151 File: slisp, Node: Arithmetic Functions, Next: Bitwise Functions, Prev: Debugging And Error Handling, Up: Xlisp Tutorial
1152
1153 Arithmetic Functions
1154 ====================
1155
1156 (truncate <expr>) TRUNCATES A FLOATING POINT NUMBER TO AN INTEGER
1157 <expr> the number
1158 returns the result of truncating the number
1159
1160 (float <expr>) CONVERTS AN INTEGER TO A FLOATING POINT NUMBER
1161 <expr> the number
1162 returns the result of floating the integer
1163
1164 (+ <expr>...) ADD A LIST OF NUMBERS
1165 <expr> the numbers
1166 returns the result of the addition
1167
1168 (- <expr>...) SUBTRACT A LIST OF NUMBERS OR NEGATE A SINGLE NUMBER
1169 <expr> the numbers
1170 returns the result of the subtraction
1171
1172 (* <expr>...) MULTIPLY A LIST OF NUMBERS
1173 <expr> the numbers
1174 returns the result of the multiplication
1175
1176 (/ <expr>...) DIVIDE A LIST OF NUMBERS
1177 <expr> the numbers
1178 returns the result of the division
1179
1180 (1+ <expr>) ADD ONE TO A NUMBER
1181 <expr> the number
1182 returns the number plus one
1183
1184 (1- <expr>) SUBTRACT ONE FROM A NUMBER
1185 <expr> the number
1186 returns the number minus one
1187
1188 (rem <expr>...) REMAINDER OF A LIST OF NUMBERS
1189 <expr> the numbers
1190 returns the result of the remainder operation
1191
1192 (min <expr>...) THE SMALLEST OF A LIST OF NUMBERS
1193 <expr> the expressions to be checked
1194 returns the smallest number in the list
1195
1196 (max <expr>...) THE LARGEST OF A LIST OF NUMBERS
1197 <expr> the expressions to be checked
1198 returns the largest number in the list
1199
1200 (abs <expr>) THE ABSOLUTE VALUE OF A NUMBER
1201 <expr> the number
1202 returns the absolute value of the number
1203
1204 (gcd <n1> <n2>...) COMPUTE THE GREATEST COMMON DIVISOR
1205 <n1> the first number (integer)
1206 <n2> the second number(s) (integer)
1207 returns the greatest common divisor
1208
1209 (random <n>) COMPUTE A RANDOM NUMBER BETWEEN 1 and N-1
1210 <n> the upper bound (integer)
1211 returns a random number
1212
1213 (sin <expr>) COMPUTE THE SINE OF A NUMBER
1214 <expr> the floating point number
1215 returns the sine of the number
1216
1217 (cos <expr>) COMPUTE THE COSINE OF A NUMBER
1218 <expr> the floating point number
1219 returns the cosine of the number
1220
1221 (tan <expr>) COMPUTE THE TANGENT OF A NUMBER
1222 <expr> the floating point number
1223 returns the tangent of the number
1224
1225 (asin <expr>) COMPUTE THE ARC SINE OF A NUMBER
1226 <expr> the floating point number
1227 returns the arc sine of the number
1228
1229 (acos <expr>) COMPUTE THE ARC COSINE OF A NUMBER
1230 <expr> the floating point number
1231 returns the arc cosine of the number
1232
1233 (atan <expr>) COMPUTE THE ARC TANGENT OF A NUMBER
1234 <expr> the floating point number
1235 returns the arc tangent of the number
1236
1237 (expt <x-expr> <y-expr>) COMPUTE X TO THE Y POWER
1238 <x-expr> the floating point number
1239 <y-expr> the floating point exponent
1240 returns x to the y power
1241
1242 (exp <x-expr>) COMPUTE E TO THE X POWER
1243 <x-expr> the floating point number
1244 returns e to the x power
1245
1246 (sqrt <expr>) COMPUTE THE SQUARE ROOT OF A NUMBER
1247 <expr> the floating point number
1248 returns the square root of the number
1249
1250 (< <n1> <n2>...) TEST FOR LESS THAN
1251 (<= <n1> <n2>...) TEST FOR LESS THAN OR EQUAL TO
1252 (= <n1> <n2>...) TEST FOR EQUAL TO
1253 (/= <n1> <n2>...) TEST FOR NOT EQUAL TO
1254 (>= <n1> <n2>...) TEST FOR GREATER THAN OR EQUAL TO
1255 (> <n1> <n2>...) TEST FOR GREATER THAN
1256 <n1> the first number to compare
1257 <n2> the second number to compare
1258 returns the result of comparing <n1> with <n2>...
1259

brinkley@uw.edu
ViewVC Help
Powered by ViewVC 1.1.26