Commit | Line | Data |
---|---|---|
3551888b JF |
1 | .Lc Data\ Structure\ Access 2 |
2 | .\".ch 2 | |
3 | .pp | |
4 | The following functions allow one to create and manipulate the various types | |
5 | of lisp data structures. | |
6 | Refer to \(sc1.3 for details of the data structures known to | |
7 | .Fr . | |
8 | .sp 3v | |
9 | .Lf *array "'s_name 's_type 'x_dim1 ... x_dim\fIn\fP" | |
10 | .Re | |
11 | an array of type s_type with n dimensions of extents given by the | |
12 | x_dim\fIi\fP. | |
13 | .No | |
14 | s_type may be any of the lisp data types or it may be t in which case | |
15 | it means an array of any type of lisp data. | |
16 | This is done by creating an array of value cells and doing an extra | |
17 | evaluation upon every reference to make it seem that the array | |
18 | contains heterogeneous data types. | |
19 | .Se | |
20 | If s_name is non nil, the value and function definition of s_name is | |
21 | set to the array structure returned. | |
22 | .No | |
23 | the above is true if you are using the default array package. | |
24 | Users who wish to make arrays look different will probably want to | |
25 | redefine *array. | |
26 | .Lf aexplode "'s_arg" | |
27 | .Re | |
28 | a list of single character symbols which | |
29 | .i print | |
30 | would use to print out | |
31 | g_arg, that is the list returned will contain quoting characters if | |
32 | .i print | |
33 | would have used them to print s_arg. | |
34 | .No | |
35 | this is restriced to symbols and is mainly for use by explode. | |
36 | .Lf aexplodec "'s_arg" | |
37 | .Re | |
38 | a list of symbols whose pnames are the characters | |
39 | in s_arg's pname. | |
40 | .\".pg | |
41 | .Lf aexploden "'s_arg" | |
42 | .Re | |
43 | a list of fixnums which represent the characters of s_arg's | |
44 | pname. | |
45 | .Lf alphalessp "'s_arg1 's_arg2" | |
46 | .Re | |
47 | t iff the print name of s_arg1 is alphabetically less than the | |
48 | print name of s_arg2. | |
49 | .Lf append "'l_arg1 'l_arg2" | |
50 | .Re | |
51 | a list containing the elemens of l_arg1 followed by l_arg2. | |
52 | .No | |
53 | To generate the result, the top level list cells of l_arg1 are duplicated | |
54 | and the cdr of the last list cell is set to point to l_arg2. | |
55 | Thus this is an expensive operation if l_arg1 is large. | |
56 | See the description of nconc for a cheaper way of doing the append. | |
57 | .Lf append1 "'l_arg1 'g_arg2" | |
58 | .Re | |
59 | a list like l_arg1 with g_arg2 as the last element. | |
60 | .No | |
61 | this is equivalent to (append 'l_arg1 (list 'g_arg2)). | |
62 | .Lf array "s_name s_type x_dim1 ... x_dim\fIi\fP" | |
63 | .No | |
64 | this is the same as *array except the arguments are not evaluated. | |
65 | .Lf arraycall "'s_type 'a_array 'x_ind1 ... " | |
66 | .Re | |
67 | the element selected by the indicies from the array a_array | |
68 | of type s_type. | |
69 | .Lf arraydims "'s_name" | |
70 | .Re | |
71 | a list of the type and bounds of the array s_name. | |
72 | .Lf arrayp "'g_arg" | |
73 | .Re | |
74 | t iff g_arg is of type array. | |
75 | .Lf arrayref "'s_name 'x_ind" | |
76 | .Re | |
77 | the x_ind\fIth\fP element of the array associated with s_name. | |
78 | x_ind of zero accesses the first element. | |
79 | .\".pg | |
80 | .Lf assoc "'g_arg1 'l_arg2" | |
81 | .Re | |
82 | the first top level element of l_arg2 whose | |
83 | .i car | |
84 | is | |
85 | .i equal | |
86 | to g_arg1. | |
87 | .No | |
88 | the test is make with the lisp function equal. | |
89 | Usually l_arg2 has an | |
90 | .i a-list | |
91 | structure and g_arg1 acts as key. | |
92 | .Lf assq "'g_arg1 'l_arg2" | |
93 | .Re | |
94 | the first top element of l_arg2 whose | |
95 | .i car | |
96 | is | |
97 | equal to g_arg1 using the | |
98 | lisp function | |
99 | .i eq. | |
100 | .No | |
101 | This is faster than assoc since eq is faster than equal but | |
102 | lisp objects which print alike are not always | |
103 | .i eq. | |
104 | See the description of eq for more details. | |
105 | .Lf atom "'g_arg" | |
106 | .Re | |
107 | t iff g_arg is not a list cell. | |
108 | .No | |
109 | (atom '()) returns t. | |
110 | .Lf bcdp "'g_arg" | |
111 | .Re | |
112 | t iff g_arg is a data object of type binary. | |
113 | .No | |
114 | the name of this function is a throwback to the PDP-11 Lisp system. | |
115 | .Lf bigp "'g_arg" | |
116 | .Re | |
117 | t iff g_arg is a bignum. | |
118 | .Lf c\.\.r "'l_arg" | |
119 | .Wh | |
120 | \.\. is any positive number of \fBa\fP's and \fBd\fP's. | |
121 | .Re | |
122 | the result of accessing the list structure in the way determined by | |
123 | the function name. | |
124 | The \fBa\fP's and \fBd\fP's are read from right to left, a | |
125 | .b d | |
126 | directing the access down the cdr part of the list cell and an | |
127 | .b a | |
128 | down the car part. | |
129 | .No | |
130 | l_arg may also be nil, and it is guaranteed that the car and cdr of nil | |
131 | is nil. | |
132 | .br | |
133 | Currently one may disect bignums with c..r as well although this is | |
134 | subject to change. | |
135 | .\".pg | |
136 | .Lf concat "['s_arg1 ... ]" | |
137 | .Re | |
138 | a symbol whose print name | |
139 | is the result of concatenating the print names | |
140 | of the s_arg\fIi\fP. | |
141 | .No | |
142 | If no arguments are given, a symbol with a null pname is returned. | |
143 | Concat places the symbol created on the oblist, the function uconcat | |
144 | does the same thing but does not place the new symbol on the oblist. | |
145 | .Lf cons "'g_arg1 'g_arg2" | |
146 | .Re | |
147 | a new list cell whose car is g_arg1 and whose cdr is g_arg2. | |
148 | .Lf copy "'g_arg" | |
149 | .Re | |
150 | A structure | |
151 | .i equal | |
152 | to g_arg but with new list cells. | |
153 | .Lf defprop "s_atm g_val g_ind" | |
154 | .Re | |
155 | g_val. | |
156 | .Se | |
157 | The property list of s_atm is updated by adding g_val as the value | |
158 | of indicator g_ind. | |
159 | .No | |
160 | this is similar to putprop except that the arguments to defprop | |
161 | are not evaluated. | |
162 | .Lf delete "'g_val 'l_list ['x_count]" | |
163 | .Re | |
164 | the result of splicing g_val from the top level of | |
165 | l_list no more than x_count times. | |
166 | .No | |
167 | x_count defaults to a very large number, thus if x_count is not given, all | |
168 | occurances of g_val are removed from the top level of l_list. | |
169 | g_val is compared with successive | |
170 | .i car 's | |
171 | of l_list using the function | |
172 | .i equal . | |
173 | .Se | |
174 | l_list is modifed using rplacd, no new list cells are used. | |
175 | .Lf delq "'g_val 'l_list ['x_count]" | |
176 | .Re | |
177 | the result of splicing g_val from the top level of l_list no more than | |
178 | x_count times. | |
179 | .No | |
180 | .i delq | |
181 | is the same as | |
182 | .i delete | |
183 | except that | |
184 | .i eq | |
185 | is used for comparison instead of | |
186 | .i equal . | |
187 | .Lf dtpr "'g_arg" | |
188 | .Re | |
189 | t iff g_arg is a list cell. | |
190 | .No | |
191 | that (dtpr '()) is nil. | |
192 | .Lf eq "'g_arg1 'g_arg2" | |
193 | .Re | |
194 | t if g_arg1 and g_arg2 are the exact same lisp object. | |
195 | .No | |
196 | .i Eq | |
197 | simply tests if g_arg1 and g_arg2 are located in the exact same | |
198 | place in memory. | |
199 | Lisp objects which print the same are not necessarily | |
200 | .i eq . | |
201 | The only objects guaranteed to be | |
202 | .i eq | |
203 | are interned symbols with the same print name. | |
204 | [Unless a symbol is created in a special way (such as with | |
205 | uconcat or maknam) | |
206 | it will be interned.] | |
207 | .Lf equal "'g_arg1 'g_arg2" | |
208 | .Re | |
209 | t iff g_arg1 and g_arg2 have the same structure as described below. | |
210 | .No | |
211 | g_arg and g_arg2 are | |
212 | .i equal | |
213 | if | |
214 | .np | |
215 | they are eq. | |
216 | .np | |
217 | they are both fixnums with the same value | |
218 | .np | |
219 | they are both flonums with the same value | |
220 | .np | |
221 | they are both bignums with the same value | |
222 | .np | |
223 | they are both lists and their cars and cdrs are | |
224 | .i equal . | |
225 | .\".pg | |
226 | .Lf explode "'g_arg" | |
227 | .Re | |
228 | a list of single character symbols which | |
229 | .i print | |
230 | would use to print g_arg. | |
231 | .Lf explodec "'g_val" | |
232 | .Re | |
233 | the list of characters which print would use to print g_val except that | |
234 | special characters in symbols are | |
235 | not escaped (just as if patom were used to print them). | |
236 | .Lf exploden "'g_val" | |
237 | .Re | |
238 | a list of fixnums which print would use to print g_val except that | |
239 | special characters in symbols are not escaped | |
240 | (just as if patom were used to print them). | |
241 | .Lf fillarray "'s_array 'l_itms" | |
242 | .Re | |
243 | s_array | |
244 | .Se | |
245 | the array s_array is filled with elements from l_itms. | |
246 | If there are not enough elements in l_itms to fill the entire array, | |
247 | then the last element of l_itms is used to fill the remaining parts | |
248 | of the array. | |
249 | .Lf gensym "'s_leader" | |
250 | .Re | |
251 | a new uninterned atom beginning with the first character of s_leader's | |
252 | pname, or beginning with g if s_leader is not given. | |
253 | .No | |
254 | The symbol looks like x0nnnnn where x is s_leader's first character and | |
255 | nnnnn is the number of times you have called gensym. | |
256 | .Lf get "'s_name 'g_ind" | |
257 | .Re | |
258 | the value under indicator g_ind in s_name's property list. | |
259 | .No | |
260 | If there is no indicator g_ind in s_name's property list nil is returned. | |
261 | If the first argument is not a symbol or disembodied property | |
262 | list, nil is returned (than atom but e lack of er, | |
263 | aclisp). | |
264 | .Lf get_pname "'s_arg" | |
265 | .Re | |
266 | the string which is the print name of s_arg. | |
267 | .\".pg | |
268 | .Lf getaccess "'a_array" | |
269 | .Re | |
270 | the access function for the array a_array. | |
271 | .Rm | |
272 | .Lf getaux "'a_array" | |
273 | .Re | |
274 | the auxilliary field for the array a_array. | |
275 | .Rm | |
276 | .Lf getchar "'s_arg 'x_index" | |
277 | .Re | |
278 | the x_index'th character of the print name of s_arg or nil if x_index | |
279 | is less than 1 or greater than the length of s_arg's print name. | |
280 | .Lf getcharn "'s_arg 'x_index" | |
281 | .Re | |
282 | the fixnum representation of the x_index'th character | |
283 | of the print name of s_arg or nil if x_index | |
284 | is less than 1 or greater than the length of s_arg's print name. | |
285 | .Lf getd "'s_arg" | |
286 | .Re | |
287 | the function definition of s_arg or nil if there is no function definition. | |
288 | .Lf getdelta "'a_array" | |
289 | .Re | |
290 | the delta field for a_array. | |
291 | .Rm | |
292 | .Lf getentry "'y_funchd" | |
293 | .Re | |
294 | the entry field of the binary y_funchd. | |
295 | .Rm | |
296 | .Lf getlength "'a_array" | |
297 | .Re | |
298 | the length field of the array a_array. | |
299 | .Rm | |
300 | .Lf implode "'l_arg" | |
301 | .Wh | |
302 | l_arg is a list of symbols and small fixnums. | |
303 | .Re | |
304 | The symbol whose print name is the result of concatentating the print names | |
305 | of the symbols in the list. | |
306 | Any fixnums are converted to the equivalent ascii character. | |
307 | .\".pg | |
308 | .Lf last "'l_arg" | |
309 | .Re | |
310 | the last list cell in the list l_arg. | |
311 | .No | |
312 | (last '(a b)) returns (b). | |
313 | .Lf length "'l_arg" | |
314 | .Re | |
315 | the number of elements in the top level of list l_arg. | |
316 | .Lf list "['g_arg1 ... ]" | |
317 | .Re | |
318 | a list whose elements are the g_arg\fIi\fP. | |
319 | .Lf maknam "'l_arg" | |
320 | .Re | |
321 | what implode would return except the resulting symbol is uninterned. | |
322 | .Lf marray "'g_data 's_access 'g_aux 'x_length 'x_delta" | |
323 | .Re | |
324 | an array type with the fields set up from the above arguments | |
325 | in the obvious way (see \(sc 1.3.9). | |
326 | .Lf member "'g_arg1 'l_arg2" | |
327 | .Re | |
328 | that part of the l_arg2 beginning with the first occurance | |
329 | of g_arg1. | |
330 | If g_arg1 is not in the top level of l_arg2, nil is returned. | |
331 | .No | |
332 | the test for equality is made with | |
333 | .i equal . | |
334 | .Lf memq "'g_arg1 'l_arg2" | |
335 | .Re. | |
336 | that part of the l_arg2 beginning with the first occurance | |
337 | of g_arg1. | |
338 | If g_arg1 is not in the top level of l_arg2, nil is returned. | |
339 | .No | |
340 | the test for equality is made with | |
341 | .i eq . | |
342 | .Lf nconc "'l_arg1 'l_arg2" | |
343 | .Re | |
344 | A list consisting of the elements of l_arg1 followed by the elements of | |
345 | l_arg2. | |
346 | .No | |
347 | The cdr of the last list cell of l_arg1 is changed to point to l_arg2. | |
348 | .\".pg | |
349 | .Lf ncons "'g_arg" | |
350 | .Re | |
351 | a new list cell with g_arg as car and nil as cdr. | |
352 | .Lf not "'g_arg" | |
353 | .Re | |
354 | t iff g_arg is nil. | |
355 | .Lf nreverse "'l_arg" | |
356 | .Re | |
357 | the reverse of l_arg. | |
358 | .No | |
359 | The reverse is done in place, that is the list structure is modified. | |
360 | No new list cells are allocated. | |
361 | .Lf nthelem "'n_arg1 'l_arg2" | |
362 | .Re | |
363 | The n_arg1'\fIst\fP element of the list l_arg2. | |
364 | .No | |
365 | If n_arg1 is non-positive or greater than the length | |
366 | of the list, nil is returned. | |
367 | .Lf null "'g_arg" | |
368 | .Re | |
369 | t iff g_arg is nil. | |
370 | .Eq | |
371 | not. | |
372 | .Lf plist "'s_name" | |
373 | .Re | |
374 | the property list of s_name. | |
375 | .Lf putaccess "'a_array 's_func" | |
376 | .Re | |
377 | s_func. | |
378 | .Se | |
379 | replaces the access field of a_array with s_func. | |
380 | .Rm | |
381 | .Lf putaux "'a_array 'g_aux" | |
382 | .Re | |
383 | s_aux. | |
384 | .Se | |
385 | replaces the auxillary field of a_array with g_aux. | |
386 | .Rm | |
387 | .\".pg | |
388 | .Lf putdelta "'a_array 'x_delta" | |
389 | .Re | |
390 | x_delta. | |
391 | .Se | |
392 | replaces the delta field of a_array with x_delta. | |
393 | .Rm | |
394 | .Lf putlength "'a_array 'x_length" | |
395 | .Re | |
396 | x_length | |
397 | .Se | |
398 | replaces the length field of a_array with x_length. | |
399 | .Rm | |
400 | .Lf putprop "'s_name 'g_val 'g_ind" | |
401 | .Re | |
402 | g_val. | |
403 | .Se | |
404 | Adds to the property list of s_name the value g_val under the indicator | |
405 | g_ind. | |
406 | .No | |
407 | this is similar to defprop except the arguments are evaluated to putprop. | |
408 | .Lf quote "g_arg" | |
409 | .Re | |
410 | g_arg. | |
411 | .No | |
412 | the reader allows you to abbreviate (quote foo) as 'foo. | |
413 | .Lf remprop "'s_name 'g_ind" | |
414 | .Re | |
415 | the portion of s_name's property list beginning with the | |
416 | property under the indicator g_ind. | |
417 | If there is no g_ind indicator in s_name's plist, nil is returned. | |
418 | .Se | |
419 | the value under indicator g_ind and g_ind itself is removed from | |
420 | the property list of s_name. | |
421 | .Lf replace "'g_arg1 'g_arg2" | |
422 | .Wh | |
423 | g_arg1 and g_arg2 must be the same type of lispval and not symbols. | |
424 | .Re | |
425 | g_arg2. | |
426 | .Se | |
427 | the contents of lispval g_arg1 is replaced by the contents of lispval g_arg2. | |
428 | .\".pg | |
429 | .Lf reverse "'l_arg" | |
430 | .Re | |
431 | the reverse of the list l_arg. | |
432 | .No | |
433 | The reverse is performed by allocating new list cells to duplicate | |
434 | the top level of l_arg. This can be expensive if l_arg is large. | |
435 | The function nreverse will reverse the list without allocating | |
436 | new list cells. | |
437 | .Lf rplaca "'l_arg1 'g_arg2" | |
438 | .Re | |
439 | the modified l_arg1. | |
440 | .Se | |
441 | the car of l_arg1 is set to g_arg2. | |
442 | .Lf rplacd "'l_arg1 'g_arg2" | |
443 | .Re | |
444 | the modified l_arg1. | |
445 | .Se | |
446 | the cdr of l_arg2 is set to g_arg2 | |
447 | .Lf set "'s_arg1 'g_arg2" | |
448 | .Re | |
449 | g_arg2. | |
450 | .Se | |
451 | the value of s_arg1 is set to g_arg2. | |
452 | .Lf setplist "'s_atm 'l_plist" | |
453 | .Re | |
454 | l_plist. | |
455 | .Se | |
456 | the property list of s_atm is set to l_plist. | |
457 | .Lf setq "s_atm1 'g_val1 [ s_atm2 'g_val2 ... ... ]" | |
458 | .Wh | |
459 | the arguments are pairs of atom names and expressions. | |
460 | .Re | |
461 | the last g_val\fIi\fP. | |
462 | .Se | |
463 | each s_atm\fIi\fP is set to have the value g_val\fIi\fP. | |
464 | .Lf stringp "'g_arg" | |
465 | .Re | |
466 | t iff g_arg is a string. | |
467 | .Lf symbolp "'g_arg" | |
468 | .Re | |
469 | t iff g_arg is an symbol. | |
470 | .Lf type "'g_arg" | |
471 | .Re | |
472 | an symbol whose pname describes the type of g_arg. | |
473 | .\".pg | |
474 | .Lf typep "'g_arg" | |
475 | .Eq | |
476 | type. | |
477 | .Lf uconcat "['s_arg1 ... ]" | |
478 | .Re | |
479 | a symbol whose pname is the result of concatenating the print names (pnames) | |
480 | of the s_arg\fIi\fP. | |
481 | .No | |
482 | If no arguments are given, a symbol with a null pname is returned. | |
483 | Uconcat does not place the symbol created on the oblist, the function concat | |
484 | does the same thing but does place the new symbol on the oblist. | |
485 | .Lf valuep "'g_arg" | |
486 | .Re | |
487 | t iff g_arg is a value cell |