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

Contents of /skandha4/info/slisp-5

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (show annotations) (download) (vendor branch)
Tue May 25 09:39:17 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: arrayp, Next: asin, Prev: aref, Up: Xlisp Language Reference
12
13 arrayp
14 ======
15
16 arrayp
17 type: predicate function (subr)
18 location: built-in
19 source file: xlbfun.c
20 Common LISP compatible: yes
21 supported on: all machines
22
23 SYNTAX
24
25 (arrayp <expr> )
26 <expr> - the expression to check
27
28 DESCRIPTION
29
30 The ARRAYP predicate checks if an <expr> is an array. T is returned
31 if <expr> is an array, NIL is returned otherwise.
32
33 EXAMPLES
34
35 (arrayp #(0 1 2)) ; returns T - array
36 (setq a #(a b c)) ;
37 (arrayp a) ; returns T - evaluates to array
38 (arrayp '(a b c)) ; returns NIL - list
39 (arrayp 1) ; returns NIL - integer
40 (arrayp 1.2) ; returns NIL - float
41 (arrayp 'a) ; returns NIL - symbol
42 (arrayp #\a) ; returns NIL - character
43 (arrayp NIL) ; returns NIL - NIL
44
45
46
47 
48 File: slisp, Node: asin, Next: assoc, Prev: arrayp, Up: Xlisp Language Reference
49
50 asin
51 ====
52
53 asin
54 type: function (subr)
55 location: built-in
56 source file: xlmath.c
57 Common LISP compatible: yes
58 supported on: all machines
59
60 SYNTAX
61
62 (asin <expr> )
63 <expr> - floating point number/expression
64
65 DESCRIPTION
66
67 The asin function returns the arc sine of the <expr>. The result is
68 in radians.
69
70 EXAMPLES
71
72 (asin 0.0) ; returns 0.0
73 (asin 1.0) ; returns 1.5708
74 (asin -1.0) ; returns -1.5708
75 (asin 0) ; error: bad integer operation
76
77
78
79 
80 File: slisp, Node: assoc, Next: atan, Prev: asin, Up: Xlisp Language Reference
81
82 assoc
83 =====
84
85 assoc
86 type: function (subr)
87 location: built-in
88 source file: xllist.c
89 Common LISP compatible: similar
90 supported on: all machines
91
92 SYNTAX
93
94 (assoc <expr> <a-list> [ { :test | :test-not } <test> ] )
95 <expr> - the expression to find - an atom or list
96 <a-list> - the association list to search
97 <test> - optional test function (default is EQL)
98
99 DESCRIPTION
100
101 An association list is a collection of list pairs of the form ( (key1
102 item1) (key2 item2) ... (keyN itemN) ). ASSOC searches through an
103 association list <a-list> looking for the key (a CAR in an association
104 pair) that matches the search <expr>. If a match is found, that
105 association pair (keyN itemN) is returned as the result. If no match is
106 found, a NIL is returned. You may specify your own test with the :TEST
107 and :TEST-NOT keywords followed by the test you which to perform.
108
109 EXAMPLES
110
111 (setq mylist '((a . my-a) (b . his-b) ; set up an association
112 (c . her-c) (d . end))) ; list
113 (assoc 'a mylist) ; returns (A . MY-A)
114 (assoc 'b mylist) ; returns (B . HIS-B)
115 (assoc 1 mylist) ; returns NIL
116 (setq agelist '((1 (bill bob)) ; set up another
117 (2 (jane jill)) ; association list
118 (3 (tim tom)) ;
119 (5 (larry daryl daryl)) ;
120 )) ;
121 (assoc 1 agelist) ; returns (1 (BILL BOB))
122 (assoc 3 agelist :test '>=) ; returns (1 (BILL BOB))
123 (assoc 3 agelist :test '<) ; returns (5 (LARRY DARYL DARYL))
124 (assoc 3 agelist :test '<=) ; returns (3 (TIM TOM))
125 (assoc 3 agelist :test-not '>=) ; returns (5 (LARRY DARYL DARYL))
126 (assoc '(a b) '( ((c d) e) ((a b) x) ) ; use a list as the search
127 :test 'equal) ; note the use of EQUAL
128 ; returns ((A B) X)
129
130 NOTE: The ASSOC function can work with a list or string as the
131 <expr>. However, the default EQL test does not work with lists or
132 strings, only symbols and numbers. To make this work, you need to use
133 the :TEST keyword along with EQUAL for <test>.
134
135 COMMON LISP COMPATIBILITY: Common LISP supports the use of the :KEY
136 keyword which specifies a function that is applied to each element of
137 <a-list> before it is tested. XLISP does not support this.
138
139
140
141 
142 File: slisp, Node: atan, Next: atom, Prev: assoc, Up: Xlisp Language Reference
143
144 atan
145 ====
146
147 atan
148 type: function (subr)
149 location: built-in
150 source file: xlmath.c
151 Common LISP compatible: yes
152 supported on: all machines
153
154 SYNTAX
155
156 (atan <expr> )
157 <expr> - floating point number/expression
158
159 DESCRIPTION
160
161 The atan function returns the arc tangent of the <expr>. The result
162 is in radians.
163
164 EXAMPLES
165
166 (atan 0.0) ; returns 0.0
167 (atan 1.0) ; returns 0.785398
168 (atan -1.0) ; returns -0.785398
169 (atan 0) ; error: bad integer operation
170
171
172
173 
174 File: slisp, Node: atom, Next: &aux, Prev: atan, Up: Xlisp Language Reference
175
176 atom
177 ====
178
179 atom
180 type: predicate function (subr)
181 location: built-in
182 source file: xlbfun.c
183 Common LISP compatible: yes
184 supported on: all machines
185
186 SYNTAX
187
188 (atom <expr> )
189 <expr> - the expression to check
190
191 DESCRIPTION
192
193 The ATOM predicate checks if the <expr> is an atom. T is returned if
194 <expr> is an atom, NIL is returned otherwise.
195
196 EXAMPLES
197
198 (atom 'a) ; returns T - symbol
199 (atom #'atom) ; returns T - subr - function
200 (atom "string") ; returns T - string
201 (atom 4) ; returns T - integer
202 (atom 4.5) ; returns T - float
203 (atom object) ; returns T - object
204 (atom #(1 2 3)) ; returns T - array
205 (atom #'quote) ; returns T - fsubr
206 (atom *standard-output*) ; returns T - stream
207 (atom '()) ; returns T - NIL is an atom
208 (atom #'defvar) ; returns T - closure - macro
209 (atom (lambda (x) (print x))) ; returns T - closure - lambda
210 (atom '(a b c)) ; returns NIL - list
211 (setq a '(a b)) ; set up A with value (A B)
212 (atom a) ; returns NIL -
213 ; value of A is not an atom
214
215 NOTE: NIL or '() is used in many places as a list-class or atom-class
216 expression. Both ATOM and LISTP, when applied to NIL, return T.
217
218
219
220 
221 File: slisp, Node: &aux, Next: backquote, Prev: atom, Up: Xlisp Language Reference
222
223 &aux
224 ====
225
226 &aux
227 type: keyword
228 location: built-in
229 source file: xleval.c
230 Common LISP compatible: yes
231 supported on: all machines
232
233 SYNTAX
234
235 &aux [ <aux-var> | ( <aux-var> <aux-value> ) ] ...
236 <aux-var> - auxiliary variable
237 <aux-value> - auxiliary variable initialization
238
239 DESCRIPTION
240
241 In XLISP, there are several times that you define a formal argument
242 list for a body of code (like DEFUN, DEFMACRO, :ANSWER and LAMBDA). The
243 <aux-var> variables are a mechanism for you to define variables local to
244 the function or operation definition. If there is an optional
245 <aux-value>, they will be set to that value on entry to the body of
246 code. Otherwise, they are initialized to NIL. At the end of the
247 function or operation execution, these local symbols and their values
248 are are removed.
249
250 EXAMPLES
251
252 (defun my-add ; define function MY-ADD
253 (num1 &rest num-list &aux sum) ; with 1 arg, rest, 1 aux var
254 (setq sum num1) ; clear SUM
255 (dotimes (i (length num-list) ) ; loop through rest list
256 (setq sum (+ sum (car num-list))) ; add the number to sum
257 (setq num-list (cdr num-list))) ; and remove num from list
258 sum) ; return sum when finished
259 (my-add 1 2 3 4) ; returns 10
260 (my-add 5 5 5 5 5) ; returns 25
261 (defun more-keys ; define MORE-KEYS
262 ( a ; with 1 parameter A
263 &aux b ; with local var B
264 (c 99) ; local var C= 99
265 (d T) ) ; local var D= T
266 (format T "a=~a " a) ; body of the function
267 (format T "b=~a " b) ;
268 (format T "c=~a " c) ;
269 (format T "d=~a " d)) ;
270 (more-keys "hi") ; prints a=hi b=NIL c=99 d=T
271
272
273
274 
275 File: slisp, Node: backquote, Next: baktrace, Prev: &aux, Up: Xlisp Language Reference
276
277 backquote
278 =========
279
280 backquote
281 type: special form (fsubr)
282 location: built-in
283 source file: xlcont.c and xlread.c
284 Common LISP compatible: yes
285 supported on: all machines
286
287 SYNTAX
288
289 (backquote <expr> )
290 <expr> - an expression which is not evaluated
291 except for comma and comma-at portions
292
293 DESCRIPTION
294
295 BACKQUOTE returns the <expr> unevaluated - like QUOTE. The
296 difference is that portions of the <expr> may be evaluated when they
297 are preceeded by a COMMA (,) or COMMA-AT (,@). COMMA will evaluate the
298 portion of the expression the comma preceeds. If the portion is an
299 atom or a list, it is placed as is within the expression. COMMA-AT
300 will evaluate the portion of the expression that the comma-at preceeds.
301 The portion needs to be a list. The list is spliced into the
302 expression. If the portion is not a list, COMMA-AT will splice in
303 nothing.
304
305 EXAMPLES
306
307 (setq box 'stuff-inside) ; BOX contains STUFF-INSIDE
308 (print box) ; prints STUFF-INSIDE
309 (quote (i have the box)) ; returns (I HAVE THE BOX)
310 (backquote (i have the box)) ; returns (I HAVE THE BOX)
311 (backquote (I have (comma box))) ; returns (I HAVE STUFF-INSIDE)
312 (backquote (I have the ,@box)) ; returns (I HAVE THE)
313 (setq automobile '(a van)) ; set up AUTOMOBILE
314 (backquote (I have automobile)) ; returns (I HAVE AUTOMOBILE)
315 (backquote (I have (comma automobile))) ; returns (I HAVE (A VAN))
316 (backquote (I have ,@automobile)) ; returns (I HAVE A VAN)
317 `(I have ,@automobile) ; returns (I HAVE A VAN)
318
319 READ MACRO: XLISP supports the normal read macro of a single reverse
320 quote (`) as a short-hand method of writing the BACKQUOTE special form.
321
322 NOTE: BACKQUOTE and COMMA and COMMA-AT are very useful in defining
323 macros via DEFMACRO.
324
325
326
327 
328 File: slisp, Node: baktrace, Next: block, Prev: backquote, Up: Xlisp Language Reference
329
330 baktrace
331 ========
332
333 baktrace
334 type: function (subr)
335 location: built-in
336 source file: xldbug.c and xlsys.c
337 Common LISP compatible: related
338 supported on: all machines
339
340 SYNTAX
341
342 (baktrace [ <level> ] )
343 <level> - an optional integer expression
344
345 DESCRIPTION
346
347 The BAKTRACE function is used to examine the system execution stack
348 from within the break look. It shows the nested forms that got the
349 system to the current state. The break loop can be entered by a system
350 error, ERROR, CERROR or BREAK functions. If the <levels> parameter is
351 not specified, all the nested forms will be shown back to the main loop
352 form that started the execution. If <level> is specified the most
353 recent <level> nested forms will be shown.
354
355 EXAMPLES
356
357 (defun out (x) (print x) (mid 99)) ; define OUT
358 (defun mid (x) (print x) (in 999)) ; define MID
359 (defun in (x) (print x) (break "in" x)) ; define IN with a BREAK
360 (out 9) ; prints 9
361 ; 99
362 ; 999
363 ; break: in - 999
364 (baktrace) ; this is done from within break loop
365 ; prints Function: #<Subr-BAKTRACE: #22cb4>
366 ; Function: #<Subr-BREAK
367 ; Arguments:
368 ; "in"
369 ; 999
370 ; Function: #<Closure-IN: #2bc44>
371 ; Arguments:
372 ; 999
373 ; Function: #<Closure-MID: #2bd20>
374 ; Arguments:
375 ; 99
376 ; Function: #<Closure-OUT: #2bec4>
377 ; Arguments:
378 ; 9
379 ; NIL
380
381 COMMON LISP COMPATIBILITY: Common LISP has a similar function called
382 BACKTRACE. For XLISP, BAKTRACE is spelled with no 'c'.
383
384
385
386 
387 File: slisp, Node: block, Next: both-case-p, Prev: baktrace, Up: Xlisp Language Reference
388
389 block
390 =====
391
392 block
393 type: special form (fsubr)
394 location: built-in
395 source file: xlcont.c
396 Common LISP compatible: yes
397 supported on: all machines
398
399 SYNTAX
400
401 (block <name> [ <body> ... ] )
402 <name> - an unevaluated symbol for the block name
403 <body> - a series of expressions
404
405 DESCRIPTION
406
407 The BLOCK special form specifies a 'named-block' construct. The last
408 expression in <body> will be returned by the BLOCK construct as its
409 result unless a RETURN or RETURN-FROM is executed within BLOCK. The
410 RETURN exit will exit the nearest (inner-most) BLOCK. The RETURN-FROM
411 exit will exit the specified block.
412
413 EXAMPLES
414
415 (block out ; outer BLOCK
416 (print "outer") ;
417 (block in ; inner BLOCK
418 (print "inner") ;
419 (return-from out "all done") ;
420 (print "won't get here") ;
421 ) ;
422 ) ; prints "outer"
423 ; prints "inner"
424 ; returns "all done"
425
426
427
428 
429 File: slisp, Node: both-case-p, Next: boundp, Prev: block, Up: Xlisp Language Reference
430
431 both-case-p
432 ===========
433
434 both-case-p
435 type: predicate function (subr)
436 location: built-in
437 source file: xlstr.c
438 Common LISP compatible: yes
439 versions: all machines
440
441 SYNTAX
442
443 (both-case-p <char> )
444 <char> - a character expression
445
446 DESCRIPTION
447
448 The BOTH-CASE-P predicate checks if the <char> expression is an
449 alphabetic character. If <char> is an alphabetic (either an upper or
450 lower case) character a T is returned, otherwise a NIL is returned.
451 Upper case characters are 'A' (ASCII decimal value 65) through 'Z'
452 (ASCII decimal value 90). Lower case characters are 'a' (ASCII decimal
453 value 97) through 'z' (ASCII decimal value 122).
454
455 EXAMPLES
456
457 (both-case-p #\A) ; returns T
458 (both-case-p #\a) ; returns T
459 (both-case-p #\1) ; returns NIL
460 (both-case-p #\[) ; returns NIL
461
462
463
464 
465 File: slisp, Node: boundp, Next: break, Prev: both-case-p, Up: Xlisp Language Reference
466
467 boundp
468 ======
469
470 boundp
471 type: predicate function (subr)
472 location: built-in
473 source file: xlbfun.c
474 Common LISP compatible: yes
475 supported on: all machines
476
477 SYNTAX
478
479 (boundp <symbol> )
480 <symbol> - the symbol expression to check for a value
481
482 DESCRIPTION
483
484 The BOUNDP predicate checks to see if <symbol> is a symbol with a
485 value bound to it. T is returned if <symbol> has a value, NIL is
486 returned otherwise. Note that <symbol> is a symbol expression - it is
487 evaluated and the resulting expression is the one that is checked.
488
489 EXAMPLES
490
491 (setq a 1) ; set up A with value 1
492 (boundp 'a) ; returns T - value is 1
493 (defun foo (x) (print x)) ; set up function FOO
494 (boundp 'foo) ; returns NIL - value is closure
495 (boundp 'defvar) ; returns NIL - value is closure
496 (boundp 'car) ; returns NIL - value is closure
497 (print myvar) ; error: unbound variable
498 (BOUNDP 'myvar) ; returns NIL
499 (setq myvar 'abc) ; set up MYVAR with a value
500 (BOUNDP 'myvar) ; returns T - because of SETQ
501 (setq myvar 'qq) ; set up MYVAR to have value QQ
502 (BOUNDP myvar) ; returns NIL - because QQ has
503 ; no value yet
504 (setq qq 'new-value) ; set QQ to have value NEW-VALUE
505 (BOUNDP myvar) ; returns T
506
507
508
509 
510 File: slisp, Node: break, Next: *breakenable*, Prev: boundp, Up: Xlisp Language Reference
511
512 break
513 =====
514
515 break
516 type: function (subr)
517 location: built-in
518 source file: xlbfun.c and xldbug.c
519 Common LISP compatible: similar
520 supported on: all machines
521
522 SYNTAX
523
524 (break [ <err-msg> [ <arg> ] ] )
525 <err-msg> - a string expression for the error message
526 <arg> - an optional expression
527
528 DESCRIPTION
529
530 The BREAK function allows the entry into the break loop with a
531 continuable error. The continuable error generated by BREAK does not
532 require any corrective action. The form of the message generated is:
533
534 break: <err-msg> - <arg>
535 if continued: return from BREAK
536
537 The default for <err-msg> is "**BREAK**". From within the
538 break-loop, if a CONTINUE form is evaluated then a NIL is returned from
539 BREAK. If desired, the CLEAN-UP and TOP-LEVEL functions may be
540 evaluated to abort out of the break loop.
541
542 EXAMPLES
543
544 (break) ; break: **BREAK**
545 (break "out") ; break: out
546 (break "it" "up") ; break: it - "up"
547
548 COMMON LISP COMPATIBILITY: Common LISP and XLISP have the same basic
549 form and style for BREAK. However, the <err-msg> string in Common LISP
550 is sent to FORMAT. FORMAT is a output function that takes in format
551 strings that include control information. Although, XLISP does have
552 the FORMAT function, it is not used for error messages. Porting from
553 XLISP to Common LISP will work fine. When porting from Common LISP to
554 XLISP, you will need to check for this embedded control information in
555 the messages.
556
557
558
559 
560 File: slisp, Node: *breakenable*, Next: car, Prev: break, Up: Xlisp Language Reference
561
562 *breakenable*
563 =============
564
565 *breakenable*
566 type: system variable
567 location: built-in
568 source file: xldbug.c
569 Common LISP compatible: no
570 supported on: all machines
571
572 SYNTAX
573
574 *breakenable*
575
576 DESCRIPTION
577
578 *BREAKENABLE* is a system variable that controls entry to the break
579 loop and the trapping of errors. If *BREAKENABLE* is set to NIL, then
580 no errors from the system, ERROR and CERROR will be trapped. If
581 *BREAKENABLE* is non-NIL, the break loop will handle these errors. The
582 BREAK function is not affected by *BREAKENABLE* and will always force
583 entry to the break loop. The INIT.LSP initialization file sets
584 *BREAKENABLE* to T, which allows errors to be trapped by the break loop.
585
586 The DEBUG function causes *BREAKENABLE* to be set to T. NODEBUG
587 causes *BREAKENABLE* to be set to NIL.
588
589 EXAMPLES
590
591 (setq *breakenable* NIL) ; disable break loop
592 (defun foo (x) (+ x x)) ; define FOO
593 (foo "a") ; error: bad argument type
594 ; but did NOT enter break loop
595 (setq *breakenable* T) ; enable break loop
596 (foo "a") ; error: bad argument type
597 ; entered break loop
598
599
600
601 
602 File: slisp, Node: car, Next: caar cadr, Prev: *breakenable*, Up: Xlisp Language Reference
603
604 car
605 ===
606
607 car
608 type: function (subr)
609 location: built-in
610 source file: xllist.c
611 Common LISP compatible: yes
612 supported on: all machines
613
614 SYNTAX
615
616 (car <expr> )
617 <expr> - a list or list expression
618
619 DESCRIPTION
620
621 CAR returns the first element of the expression. If the first
622 expression is itself a list, then the sublist is returned. If the list
623 is NIL, NIL is returned.
624
625 EXAMPLES
626
627 (car '(a b c)) ; returns A
628 (car '((a b) c d)) ; returns (A B)
629 (car NIL) ; returns NIL
630 (car 'a) ; error: bad argument type
631 (setq bob '(1 2 3)) ; set up variable BOB
632 (car bob) ; returns 1
633
634
635
636 
637 File: slisp, Node: caar cadr, Next: caaar caadr cadar caddr, Prev: car, Up: Xlisp Language Reference
638
639 caar cadr
640 =========
641
642 caar cadr
643 type: function (subr)
644 location: built-in
645 source file: xllist.c
646 Common LISP compatible: yes
647 supported on: all machines
648
649 SYNTAX
650
651 (caar <expr> )
652 (cadr <expr> )
653 <expr> - a list or list expression
654
655 DESCRIPTION
656
657 The CAAR and CADR functions go through the list expression and
658 perform a sequence of CAR/CDR operations. The sequence of operations
659 is performed from right to left. So CADR does a CDR on the expression,
660 followed by a CAR. If at any point the list is NIL, NIL is returned.
661 If at any point a CAR operation is performed on an atom (as opposed to
662 a list) an error is reported - "error: BAD ARGUMENT".
663
664 EXAMPLES
665
666 (setq mylist '( (a1 a2) ; make a 2-level list
667 (b1 b2)
668 (c1 c2)
669 (d1 d2) ) )
670 (caar mylist) ; returns A1
671 (cadr mylist) ; returns (B1 B2)
672 (cdar mylist) ; returns (A2)
673 (cddr mylist) ; returns ((C1 C2) (D1 D2))
674 (caar 'a) ; error: bad argument
675 (caar nil) ; returns NIL
676 (cadr nil) ; returns NIL
677 (cdar nil) ; returns NIL
678 (cddr nil) ; returns NIL
679
680
681
682 
683 File: slisp, Node: caaar caadr cadar caddr, Next: caaaar caaadr ... caddar cadddr, Prev: caar cadr, Up: Xlisp Language Reference
684
685 caaar caadr cadar caddr
686 =======================
687
688 caaar caadr cadar caddr
689 type: function (subr)
690 location: built-in
691 source file: xllist.c
692 Common LISP compatible: yes
693 supported on: all machines
694
695 SYNTAX
696
697 (caaar <expr> )
698 (caadr <expr> )
699 (cadar <expr> )
700 (caddr <expr> )
701 <expr> - a list or list expression
702
703 DESCRIPTION
704
705 The CAAAR, CAADR, CADAR and CADDR functions go through the list
706 expression and perform a sequence of CAR/CDR operations. The sequence
707 of operations is performed from right to left. So CADDR does a CDR on
708 the expression, followed by a CDR, followed by a CAR. If at any point
709 the list is NIL, NIL is returned. If at any point a CAR operation is
710 performed on an atom (as opposed to a list) an error is reported -
711 "error: BAD ARGUMENT".
712
713 EXAMPLES
714
715 (setq mylist '( ( (a b) (c d) (e f) ) ; make a 3-level list
716 ( (g h) (i j) (k l) )
717 ( (m n) (o p) (q r) )
718 ( (s t) (u v) (w x) )
719 ) )
720 (caaar mylist) ; returns A
721 (caadr mylist) ; returns (G H)
722 (cadar mylist) ; returns (C D)
723 (caddr mylist) ; returns ((M N) (O P) (Q R))
724 (cdaar mylist) ; returns (B)
725 (cdadr mylist) ; returns ((I J) (K L))
726 (cddar mylist) ; returns ((E F))
727 (cdddr mylist) ; returns (((S T) (U V) (W X)))
728
729
730
731 
732 File: slisp, Node: caaaar caaadr ... caddar cadddr, Next: case, Prev: caaar caadr cadar caddr, Up: Xlisp Language Reference
733
734 caaaar caaadr ... caddar cadddr
735 ===============================
736
737 caaaar caaadr ... caddar cadddr
738 type: function (subr)
739 location: built-in
740 source file: xllist.c
741 Common LISP compatible: yes
742 supported on: all machines
743
744 SYNTAX
745
746 (caaaar <expr> )
747 (caaadr <expr> )
748 (caadar <expr> )
749 ...
750 (caddar <expr> )
751 (cadddr <expr> )
752 <expr> - a list or list expression
753
754 DESCRIPTION
755
756 The CAAAAR, CAAADR ... CADDAR, CADDDR functions go through the list
757 expression and perform a sequence of CAR/CDR operations. The sequence
758 of operations is performed from right to left. So CAADDR does a CDR on
759 the expression, followed by a CDR, followed by a CAR, followed by
760 another CAR. If at any point the list is NIL, NIL is returned. If at
761 anypoint a CAR operation is performed on an atom (as opposed to a list)
762 an error is reported - "error: BAD ARGUMENT".
763
764 EXAMPLES
765
766 (setq mylist '( ( (a b) (c d) (e f) ) ; make a 3-level list
767 ( (g h) (i j) (k l) )
768 ( (m n) (o p) (q r) )
769 ( (s t) (u v) (w x) )
770 ) )
771 (caaadr mylist) ; returns G
772 (caadar mylist) ; returns C
773 (cdadar mylist) ; returns (D)
774 (cadadr mylist) ; returns (I J)
775 (cdaddr mylist) ; returns ((O P) (Q R))
776 (cadddr mylist) ; returns ((S T) (U V) (W X))
777
778
779
780 
781 File: slisp, Node: case, Next: catch, Prev: caaaar caaadr ... caddar cadddr, Up: Xlisp Language Reference
782
783 case
784 ====
785
786 case
787 type: special form (fsubr)
788 location: built-in
789 source file: xlcont.c
790 Common LISP compatible: similar
791 supported on: all machines
792
793 SYNTAX
794
795 (case <expr> [ ( <value> <action> ) ... ] )
796 <expr> - an expression
797 <value> - an unevaluated expression or list of unevaluated
798 expressions to compare against <expr>
799 <action> - an expression
800
801 DESCRIPTION
802
803 The CASE special form is a selection control form. CASE evaluates
804 <expr>. This value is then compared against all the <value> entries.
805 If <value> is a single atom, the atom is compared against <expr>. If
806 <value> is a list, each of the elements of the list are compared against
807 <expr>. The <action> associated with the first <value> that matches
808 <expr> is evaluated and returned as CASE's result. If no <value>
809 matches, a NIL is returned. If the last <value> is the T symbol and no
810 other <value> has matched <expr>, then CASE will evaluate the <action>
811 associated with T. If there are multiple T entries, the first is
812 considered to be the end of the CASE.
813
814 EXAMPLES
815
816 (case 'a ('a "a")) ; returns "a"
817 (case 'a ('b "b")) ; returns NIL
818 (case 9 ( 1 "num") (t "ho") (t "hi")) ; returns "ho"
819 (case 'a ((1 2 3 4) "number") ;
820 ( (a b c d) "alpha")) ; returns "alpha"
821 (case 'a) ; returns NIL
822 (case) ; returns NIL
823 (defun print-what (parm) ; define a function
824 (case (type-of parm) ; check PARM type
825 ( flonum (print "float")) ;
826 ( fixnum (print "integer")) ;
827 ( string (print "string")) ;
828 ( cons (print "list")) ;
829 ( T (print "other"))) ; otherwise
830 NIL) ; and always return NIL
831 (print-what 1.2) ; prints "float" returns NIL
832 (print-what 3) ; prints "integer" returns NIL
833 (print-what "ab") ; prints "string" returns NIL
834 (print-what '(a b)) ; prints "list" returns NIL
835 (print-what 'a) ; prints "other" returns NIL
836
837 NOTE: The CASE special form does not work with a list or string as
838 the <expr>. This is because CASE defines the test used to be the EQL
839 test which does not work with lists or strings, only symbols and
840 numbers.
841
842 COMMON LISP COMPATIBILITY: In XLISP, you can use the value T as the
843 last value to get the effect of 'otherwise'. Common LISP uses the
844 symbol OTHERWISE and T for this. If you are porting in code from
845 Common LISP, be careful to make sure T is used instead of OTHERWISE in
846 CASE statements. (Note that no error will be generated, XLISP will
847 just try to match the <expr> to OTHERWISE.
848
849
850
851 
852 File: slisp, Node: catch, Next: cdr, Prev: case, Up: Xlisp Language Reference
853
854 catch
855 =====
856
857 catch
858 type: special form (fsubr)
859 location: built-in
860 source file: xlcont.c
861 Common LISP compatible: yes
862 supported on: all machines
863
864 SYNTAX
865
866 (catch <tag-symbol> [ <expr> ... ] )
867 <tag-symbol> - an expression that evaluates to a symbol
868 <expr> - an optional series of expressions to be
869 evaluated
870
871 DESCRIPTION
872
873 The CATCH and THROW special forms allow for non-local exits and traps
874 without going through the intermediate evaluations and function returns.
875 If there is a CATCH for a <sym-tag> that has no THROW performed to it,
876 CATCH returns the value returned from <expr>. If there is no <expr>, a
877 NIL is returned. If a THROW is evaluated with no corresponding CATCH,
878 an error is generated - "error: no target for THROW". If, in the
879 calling process, more than one CATCH is set up for the same
880 <tag-symbol>, the most recently evaluated <tag-symbol> will be the one
881 that does the actual catching.
882
883 EXAMPLES
884
885 (catch 'mytag) ; returns NIL - no THROW
886 (catch 'mytag (+ 1 (+ 2 3))) ; returns 6 - no THROW
887 (catch 'mytag (+ 1 (throw 'mytag))) ; returns NIL - caught it
888 (catch 'mytag (+ 1 (throw 'mytag 55))) ; returns 55 - caught it
889 (catch 'mytag (throw 'foo)) ; error: no target for THROW
890 (defun in (x) ; define IN
891 (if (numberp x) (+ x x) ; if number THEN double
892 (throw 'math 42))) ; ELSE throw 42
893 (defun out (x) ; define OUT
894 (princ "<") ;
895 (princ (* (in x) 2)) ; double via multiply
896 (princ ">") "there") ;
897 (defun main (x) ; define MAIN
898 (catch 'math (out x))) ; with CATCH
899 (in 5) ; returns 10
900 (out 5) ; prints <20> returns "there"
901 (main 5) ; prints <20> returns "there"
902 (main 'a) ; prints < returns 42
903
904 NOTE: Although CATCH and THROW will accept a <tag-symbol> that is
905 not a symbol, it will not find this improper <tag-symbol>. An error
906 will be generated - "error: no target for THROW".
907
908
909
910 
911 File: slisp, Node: cdr, Next: cdar cddr, Prev: catch, Up: Xlisp Language Reference
912
913 cdr
914 ===
915
916 cdr
917 type: function (subr)
918 location: built-in
919 source file: xllist.c
920 Common LISP compatible: yes
921 supported on: all machines
922
923 SYNTAX
924
925 (cdr <expr> )
926 <expr> - a list or list expression
927
928 DESCRIPTION
929
930 CDR returns the remainder of a list or list expression after first
931 element of the list is removed. If the list is NIL, NIL is returned.
932
933 EXAMPLES
934
935 (cdr '(a b c)) ; returns (B C)
936 (cdr '((a b) c d)) ; returns (C D)
937 (cdr NIL) ; returns NIL
938 (cdr 'a) ; error: bad argument type
939 (cdr '(a)) ; returns NIL
940 (setq ben '(a b c)) ; set up variable BEN
941 (cdr ben) ; returns (B C)
942
943
944
945 
946 File: slisp, Node: cdar cddr, Next: cdaar cdadr cddar cdddr cdar cddr, Prev: cdr, Up: Xlisp Language Reference
947
948 cdar cddr
949 =========
950
951 cdar cddr
952 type: function (subr)
953 location: built-in
954 source file: xllist.c
955 Common LISP compatible: yes
956 supported on: all machines
957
958 SYNTAX
959
960 (cdar <expr> )
961 (cddr <expr> )
962 <expr> - a list or list expression
963
964 DESCRIPTION
965
966 The CDAR and CDDR functions go through the list expression and
967 perform a sequence of CAR/CDR operations. The sequence of operations
968 is performed from right to left. So CDAR does a CAR on the expression,
969 followed by a CDR. If at any point the list is NIL, NIL is returned.
970 If at any point a CAR operation is performed on an atom (as opposed to
971 a list) an error is reported - "error: BAD ARGUMENT".
972
973 EXAMPLES
974
975 (setq mylist '( (a1 a2) ; make a 2-level list
976 (b1 b2)
977 (c1 c2)
978 (d1 d2) ) )
979 (cdar mylist) ; returns (A2)
980 (cddr mylist) ; returns ((C1 C2) (D1 D2))
981 (caar mylist) ; returns A1
982 (cadr mylist) ; returns (B1 B2)
983 (caar 'a) ; error: bad argument
984 (caar nil) ; returns NIL
985 (cadr nil) ; returns NIL
986 (cdar nil) ; returns NIL
987 (cddr nil) ; returns NIL
988
989
990
991 
992 File: slisp, Node: cdaar cdadr cddar cdddr cdar cddr, Next: cdaaar cdaadr ... cdddar cddddr, Prev: cdar cddr, Up: Xlisp Language Reference
993
994 cdaar cdadr cddar cdddr cdar cddr
995 =================================
996
997 cdaar cdadr cddar cdddr
998 type: function (subr)
999 location: built-in
1000 source file: xllist.c
1001 Common LISP compatible: yes
1002 supported on: all machines
1003
1004 SYNTAX
1005
1006 (cdaar <expr> )
1007 (cdadr <expr> )
1008 (cddar <expr> )
1009 (cdddr <expr> )
1010 <expr> - a list or list expression
1011
1012 DESCRIPTION
1013
1014 The CDAAR, CDADR, CDDAR and CDDDR functions go through the list
1015 expression and perform a sequence of CAR/CDR operations. The sequence
1016 of operations is performed from right to left. So CDDAR does a CAR on
1017 the expression, followed by a CDR, followed by another CDR. If at any
1018 point the list is NIL, NIL is returned. If at any point a CAR operation
1019 is performed on an atom (as opposed to a list) an error is reported -
1020 "error: BAD ARGUMENT".
1021
1022 EXAMPLES
1023
1024 (setq mylist '( ( (a b) (c d) (e f) ) ; make a 3-level list
1025 ( (g h) (i j) (k l) )
1026 ( (m n) (o p) (q r) )
1027 ( (s t) (u v) (w x) )
1028 ) )
1029 (cdaar mylist) ; returns (B)
1030 (cdadr mylist) ; returns ((I J) (K L))
1031 (cddar mylist) ; returns ((E F))
1032 (cdddr mylist) ; returns (((S T) (U V) (W X)))
1033 (caaar mylist) ; returns A
1034 (caadr mylist) ; returns (G H)
1035 (cadar mylist) ; returns (C D)
1036 (caddr mylist) ; returns ((M N) (O P) (Q R))
1037
1038
1039
1040 
1041 File: slisp, Node: cdaaar cdaadr ... cdddar cddddr, Next: cerror, Prev: cdaar cdadr cddar cdddr cdar cddr, Up: Xlisp Language Reference
1042
1043 cdaaar cdaadr ... cdddar cddddr
1044 ===============================
1045
1046 cdaaar cdaadr ... cdddar cddddr
1047 type: function (subr)
1048 location: built-in
1049 source file: xllist.c
1050 Common LISP compatible: yes
1051 supported on: all machines
1052
1053 SYNTAX
1054
1055 (cdaaar <expr> )
1056 (cdaadr <expr> )
1057 ...
1058 (cdddar <expr> )
1059 (cddddr <expr> )
1060 <expr> - a list or list expression
1061
1062 DESCRIPTION
1063
1064 The CDAAAR, CDAADR .... CDDDAR, CDDDDR functions go through the list
1065 expression and perform a sequence of CAR/CDR operations. The sequence
1066 of operations is performed from right to left. So CDDAAR does a CAR on
1067 the expression, followed by a CAR, followed by a CDR, followed by
1068 another CDR. If at any point the list is NIL, NIL is returned. If at
1069 anypoint a CAR operation is performed on an atom (as opposed to a list)
1070 an error is reported - "error: BAD ARGUMENT".
1071
1072 EXAMPLES
1073
1074 (setq mylist '( ( (a b) (c d) (e f) ) ; make a 3-level list
1075 ( (g h) (i j) (k l) )
1076 ( (m n) (o p) (q r) )
1077 ( (s t) (u v) (w x) )
1078 ) )
1079 (cdadar mylist) ; returns (D)
1080 (cdaddr mylist) ; returns ((O P) (Q R))
1081 (caaadr mylist) ; returns G
1082 (cadadr mylist) ; returns (I J)
1083 (caadar mylist) ; returns C
1084 (cadddr mylist) ; returns ((S T) (U V) (W X))
1085
1086
1087
1088 
1089 File: slisp, Node: cerror, Next: char, Prev: cdaaar cdaadr ... cdddar cddddr, Up: Xlisp Language Reference
1090
1091 cerror
1092 ======
1093
1094 cerror
1095 type: function (subr)
1096 location: built-in
1097 source file: xlbfun.c and xldbug.c
1098 Common LISP compatible: similar
1099 supported on: all machines
1100
1101 SYNTAX
1102
1103 (cerror <cont-msg> <err-msg> [ <arg> ] )
1104 <cont-msg> - a string expression for the continue message
1105 <err-msg> - a string expression for the error message
1106 <arg> - an optional expression
1107
1108 DESCRIPTION
1109
1110 The CERROR function allows the generation of a continuable error. A
1111 continuable error is one that can be corrected by some action within the
1112 XLISP break loop. The form of the message generated is:
1113
1114 error: <err-msg> - <arg>
1115 if continued: <cont-msg>
1116
1117 From within the break-loop, if a CONTINUE form is evaluated then a
1118 NIL is returned from CERROR. From within the break loop, forms can be
1119 evaluated to correct the error. If desired, the CLEAN-UP and TOP-LEVEL
1120 forms may be evaluated to abort out of the break loop.
1121
1122 EXAMPLES
1123
1124 (cerror "fee" "fi" "fo") ; CERROR generates the message -
1125 ; error: fi - "fo"
1126 ; if continued: fee
1127 (cerror "I will do better" ; CERROR generates the message -
1128 "There's a problem, Dave") ;
1129 ; error: There's a problem, Dave
1130 ; if continued: I will do better
1131 ; example of system generated
1132 ; correctable error -
1133 (symbol-value 'f) ; error: unbound variable - F
1134 ; if continued:
1135 ; try evaluating symbol again
1136
1137 COMMON LISP COMPATIBILITY: Common LISP and XLISP have the same basic
1138 form and style for CERROR. However, the <err-msg> and <cont-msg>
1139 string in Common LISP is sent to FORMAT. FORMAT is a output function
1140 that takes in format strings that include control information.
1141 Although, XLISP does have the FORMAT function, it does not print the
1142 CERROR <err-msg> with FORMAT. So, Porting from XLISP to Common LISP
1143 will work fine. When porting from Common LISP to XLISP, you will need
1144 to check for this embedded control information in the error messages.
1145
1146 NOTE: In the XLISP system, the only correctable system errors have
1147 to do with the value of a symbol being unbound. In these cases, you
1148 can do a SETQ or SET from within the break loop and then CONTINUE.
1149
1150 NOTE: Remember that *BREAKENABLE* needs to non-NIL for ERROR and
1151 CERROR and system errors to be caught by the normal system break loop.
1152 If *BREAKENABLE* is NIL, ERROR and CERROR and system errors can be
1153 caught by an ERRSET form. If there is no surrounding ERRSET, no error
1154 message is generated and the break loop is not entered.
1155
1156
1157
1158 
1159 File: slisp, Node: char, Next: char/=, Prev: cerror, Up: Xlisp Language Reference
1160
1161 char
1162 ====
1163
1164 char
1165 type: function (subr)
1166 location: built-in
1167 source file: xlstr.c
1168 Common LISP compatible: yes
1169 supported on: all machines
1170
1171 SYNTAX
1172
1173 (char <string> <position> )
1174 <string> - a string expression
1175 <position> - an integer expression
1176
1177 DESCRIPTION
1178
1179 The CHAR function returns the ASCII numeric value of the character at
1180 the specified <position> in the <string>. A <position> of 0 is the
1181 first character in the string.
1182
1183 EXAMPLES
1184 (char "12345" 0) ; returns #\1
1185 (char "12 45" 2) ; returns #\Space
1186 (string (char "1234" 3)) ; returns "4"
1187 (char "1234" 9) ; error: index out of range
1188
1189
1190
1191 
1192 File: slisp, Node: char/=, Next: char<, Prev: char, Up: Xlisp Language Reference
1193
1194 char/=
1195 ======
1196
1197 char/=
1198 type: function (subr)
1199 location: built-in
1200 source file: xlstr.c
1201 Common LISP compatible: yes
1202 supported on: all machines
1203
1204 SYNTAX
1205
1206 (char/= <char1> <charN> ... )
1207 <char1> - a character expression
1208 <charN> - character expression(s) to compare
1209
1210 DESCRIPTION
1211
1212 The CHAR/= (character-NOT-EQUAL) function takes one or more character
1213 arguments. It checks to see if all the character arguments are
1214 different values. T is returned if the arguments are of different ASCII
1215 value. In the case of two arguments, this has the effect of testing if
1216 <char1> is not equal to <char2>. This test is case sensitive - the
1217 character #\a is different (and of greater ASCII value) than #\A.
1218
1219 EXAMPLES
1220
1221 (char/= #\a #\b) ; returns T
1222 (char/= #\a #\b #\c) ; returns T
1223 (char/= #\a #\a) ; returns NIL
1224 (char/= #\a #\b #\b) ; returns NIL
1225 (char/= #\A #\a) ; returns T
1226 (char/= #\a #\A) ; returns T
1227
1228 NOTE: Be sure that the CHAR/= function is properly typed in. The
1229 '/' is a forward slash. It is possible to mistakenly type a '\'
1230 (backslash). This is especially easy because the character mechanism
1231 is '#\a'. If you do use the backslash, no error will be reported
1232 because backslash is the single escape character and the LISP reader
1233 will evaluate 'CHAR\=' as 'CHAR='. No error will be reported, but the
1234 sense of the test is reversed.
1235
1236
1237
1238 
1239 File: slisp, Node: char<, Next: char<=, Prev: char/=, Up: Xlisp Language Reference
1240
1241 char<
1242 =====
1243
1244 char<
1245 type: function (subr)
1246 location: built-in
1247 source file: xlstr.c
1248 Common LISP compatible: yes
1249 supported on: all machines
1250
1251 SYNTAX
1252
1253 (char< <char1> <charN> ... )
1254 <char1> - a character expression
1255 <charN> - character expression(s) to compare
1256
1257 DESCRIPTION
1258
1259 The CHAR< (character-LESS-THAN) function takes one or more character
1260 arguments. It checks to see if all the character arguments are
1261 monotonically increasing. T is returned if the arguments are of
1262 increasing ASCII value. In the case of two arguments, this has the
1263 effect of testing if <char1> is less than <char2>. This test is case
1264 sensitive - the character #\a is different (and of greater ASCII value)
1265 than #\A.
1266
1267 EXAMPLES
1268
1269 (char< #\a #\b) ; returns T
1270 (char< #\b #\a) ; returns NIL
1271 (char< #\a #\b #\c) ; returns T
1272 (char< #\a #\a) ; returns NIL
1273 (char< #\a #\b #\b) ; returns NIL
1274 (char< #\A #\a) ; returns T
1275 (char< #\a #\A) ; returns NIL
1276
1277
1278
1279 
1280 File: slisp, Node: char<=, Next: char=, Prev: char<, Up: Xlisp Language Reference
1281
1282 char<=
1283 ======
1284
1285 char<=
1286 type: function (subr)
1287 location: built-in
1288 source file: xlstr.c
1289 Common LISP compatible: yes
1290 supported on: all machines
1291
1292 SYNTAX
1293
1294 (char<= <char1> <charN> ... )
1295 <char1> - a character expression
1296 <charN> - character expression(s) to compare
1297
1298 DESCRIPTION
1299
1300 The CHAR<= (character-LESS-THAN-OR-EQUAL) function takes one or more
1301 character arguments. It checks to see if all the character arguments
1302 are monotonically non-decreasing. T is returned if the arguments are of
1303 non-decreasing ASCII value. In the case of two arguments, this has the
1304 effect of testing if <char1> is less than or equal to <char2>. This
1305 test is case sensitive - the character #\a is different (and of greater
1306 ASCII value) than #\A.
1307
1308 EXAMPLES
1309
1310 (char<= #\a #\b) ; returns T
1311 (char<= #\b #\a) ; returns NIL
1312 (char<= #\a #\b #\c) ; returns T
1313 (char<= #\a #\a) ; returns T
1314 (char<= #\a #\b #\b) ; returns T
1315 (char<= #\A #\a) ; returns T
1316 (char<= #\a #\A) ; returns NIL
1317
1318
1319
1320 
1321 File: slisp, Node: char=, Next: char>, Prev: char<=, Up: Xlisp Language Reference
1322
1323 char=
1324 =====
1325
1326 char=
1327 type: function (subr)
1328 location: built-in
1329 source file: xlstr.c
1330 Common LISP compatible: yes
1331 supported on: all machines
1332
1333 SYNTAX
1334
1335 (char= <char1> <charN> ... )
1336 <char1> - a character expression
1337 <charN> - character expression(s) to compare
1338
1339 DESCRIPTION
1340
1341 The CHAR= (character-EQUALITY) function takes one or more character
1342 arguments. It checks to see if all the character arguments are
1343 equivalent. T is returned if the arguments are of the same ASCII value.
1344 In the case of two arguments, this has the effect of testing if <char1>
1345 is equal to <char2>. This test is case sensitive - the character #\a is
1346 different (and of greater ASCII value) than #\A.
1347
1348 EXAMPLES
1349
1350 (char= #\a #\b) ; returns NIL
1351 (char= #\b #\a) ; returns NIL
1352 (char= #\a #\b #\c) ; returns NIL
1353 (char= #\a #\a) ; returns T
1354 (char= #\a #\a #\a) ; returns T
1355 (char= #\a #\a #\b) ; returns NIL
1356 (char= #\A #\a) ; returns NIL
1357 (char= #\a #\A) ; returns NIL
1358
1359
1360
1361 
1362 File: slisp, Node: char>, Next: char>=, Prev: char=, Up: Xlisp Language Reference
1363
1364 char>
1365 =====
1366
1367 char>
1368 type: function (subr)
1369 location: built-in
1370 source file: xlstr.c
1371 Common LISP compatible: yes
1372 supported on: all machines
1373
1374 SYNTAX
1375
1376 (char> <char1> <charN> ... )
1377 <char1> - a character expression
1378 <charN> - character expression(s) to compare
1379
1380 DESCRIPTION
1381
1382 The CHAR> (character-GREATER-THAN) function takes one or more
1383 character arguments. It checks to see if all the character arguments
1384 are monotonically decreasing. T is returned if the arguments are of
1385 monotonically decreasing ASCII value. In the case of two arguments,
1386 this has the effect of testing if <char1> is greater than <char2>. This
1387 test is case sensitive - the character #\a is different (and of greater
1388 ASCII value) than #\A.
1389
1390 EXAMPLES
1391
1392 (char> #\a #\b) ; returns NIL
1393 (char> #\b #\a) ; returns T
1394 (char> #\c #\b #\a) ; returns T
1395 (char> #\a #\a) ; returns NIL
1396 (char> #\c #\a #\b) ; returns NIL
1397 (char> #\A #\a) ; returns NIL
1398 (char> #\a #\A) ; returns T
1399
1400
1401

brinkley@uw.edu
ViewVC Help
Powered by ViewVC 1.1.26