-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathgcl.info-36
1625 lines (1116 loc) · 48.8 KB
/
gcl.info-36
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
This is Info file gcl.info, produced by Makeinfo-1.55 from the input file
gcl.texi.
This is a Texinfo GNU Common Lisp Manual based on the draft ANSI standard
for Common Lisp.
Copyright 1994 William F. Schelter
File: gcl.info, Node: member, Next: mapc, Prev: rest, Up: Conses Dictionary
member, member-if, member-if-not [Function]
---------------------------------------------------------------------------
`member' item list &key key test test-not => tail
`member-if' predicate list &key key => tail
`member-if-not' predicate list &key key => tail
Arguments and Values::
......................
item--an object.
list--a proper list.
predicate--a designator for a function of one argument that returns a
generalized boolean.
test--a designator for a function of two arguments that returns a
generalized boolean.
test-not--a designator for a function of two arguments that returns a
generalized boolean.
key--a designator for a function of one argument, or nil.
tail--a list.
Description::
.............
member, member-if, and member-if-not each search list for item or for a
top-level element that satisfies the test. The argument to the predicate
function is an element of list.
If some element satisfies the test, the tail of list beginning with this
element is returned; otherwise nil is returned.
list is searched on the top level only.
Examples::
..........
(member 2 '(1 2 3)) => (2 3)
(member 2 '((1 . 2) (3 . 4)) :test-not #'= :key #'cdr) => ((3 . 4))
(member 'e '(a b c d)) => NIL
(member-if #'listp '(a b nil c d)) => (NIL C D)
(member-if #'numberp '(a #\Space 5/3 foo)) => (5/3 FOO)
(member-if-not #'zerop
'(3 6 9 11 . 12)
:key #'(lambda (x) (mod x 3))) => (11 . 12)
Exceptional Situations::
........................
Should be prepared to signal an error of type type-error if list is not a
proper list.
See Also::
..........
*Note find; find-if; find-if-not:: , *Note position; position-if;
position-if-not:: ,
*Note Traversal Rules and Side Effects::
Notes::
.......
The :test-not parameter is deprecated.
The function member-if-not is deprecated.
In the following
(member 'a '(g (a y) c a d e a f)) => (A D E A F)
the value returned by member is identical to the portion of the list
beginning with a. Thus rplaca on the result of member can be used to
alter the part of the list where a was found (assuming a check has been
made that member did not return nil).
File: gcl.info, Node: mapc, Next: acons, Prev: member, Up: Conses Dictionary
mapc, mapcar, mapcan, mapl, maplist, mapcon [Function]
---------------------------------------------------------------------------
`mapc' function &rest lists^+ => list-1
`mapcar' function &rest lists^+ => result-list
`mapcan' function &rest lists^+ => concatenated-results
`mapl' function &rest lists^+ => list-1
`maplist' function &rest lists^+ => result-list
`mapcon' function &rest lists^+ => concatenated-results
Arguments and Values::
......................
function--a designator for a function that must take as many arguments as
there are lists.
list--a proper list.
list-1--the first list (which must be a proper list).
result-list--a list.
concatenated-results--a list.
Description::
.............
The mapping operation involves applying function to successive sets of
arguments in which one argument is obtained from each sequence. Except
for mapc and mapl, the result contains the results returned by function.
In the cases of mapc and mapl, the resulting sequence is list.
function is called first on all the elements with index 0, then on all
those with index 1, and so on. result-type specifies the type of the
resulting sequence.
If function is a symbol, it is coerced to a function as if by
symbol-function.
mapcar operates on successive elements of the lists. function is applied
to the first element of each list, then to the second element of each
list, and so on. The iteration terminates when the shortest list runs out,
and excess elements in other lists are ignored. The value returned by
mapcar is a list of the results of successive calls to function.
mapc is like mapcar except that the results of applying function are not
accumulated. The list argument is returned.
maplist is like mapcar except that function is applied to successive
sublists of the lists. function is first applied to the lists themselves,
and then to the cdr of each list, and then to the cdr of the cdr of each
list, and so on.
mapl is like maplist except that the results of applying function are not
accumulated; list-1 is returned.
mapcan and mapcon are like mapcar and maplist respectively, except that
the results of applying function are combined into a list by the use of
nconc rather than list. That is,
(mapcon f x1 ... xn)
== (apply #'nconc (maplist f x1 ... xn))
and similarly for the relationship between mapcan and mapcar.
Examples::
..........
(mapcar #'car '((1 a) (2 b) (3 c))) => (1 2 3)
(mapcar #'abs '(3 -4 2 -5 -6)) => (3 4 2 5 6)
(mapcar #'cons '(a b c) '(1 2 3)) => ((A . 1) (B . 2) (C . 3))
(maplist #'append '(1 2 3 4) '(1 2) '(1 2 3))
=> ((1 2 3 4 1 2 1 2 3) (2 3 4 2 2 3))
(maplist #'(lambda (x) (cons 'foo x)) '(a b c d))
=> ((FOO A B C D) (FOO B C D) (FOO C D) (FOO D))
(maplist #'(lambda (x) (if (member (car x) (cdr x)) 0 1)) '(a b a c d b c))
=> (0 0 1 0 1 1 1)
;An entry is 1 if the corresponding element of the input
; list was the last instance of that element in the input list.
(setq dummy nil) => NIL
(mapc #'(lambda (&rest x) (setq dummy (append dummy x)))
'(1 2 3 4)
'(a b c d e)
'(x y z)) => (1 2 3 4)
dummy => (1 A X 2 B Y 3 C Z)
(setq dummy nil) => NIL
(mapl #'(lambda (x) (push x dummy)) '(1 2 3 4)) => (1 2 3 4)
dummy => ((4) (3 4) (2 3 4) (1 2 3 4))
(mapcan #'(lambda (x y) (if (null x) nil (list x y)))
'(nil nil nil d e)
'(1 2 3 4 5 6)) => (D 4 E 5)
(mapcan #'(lambda (x) (and (numberp x) (list x)))
'(a 1 b c 3 4 d 5))
=> (1 3 4 5)
In this case the function serves as a filter; this is a standard Lisp
idiom using mapcan.
(mapcon #'list '(1 2 3 4)) => ((1 2 3 4) (2 3 4) (3 4) (4))
Exceptional Situations::
........................
Should be prepared to signal an error of type type-error if any list is
not a proper list.
See Also::
..........
*Note dolist:: , *Note map:: ,
*Note Traversal Rules and Side Effects::
File: gcl.info, Node: acons, Next: assoc, Prev: mapc, Up: Conses Dictionary
acons [Function]
---------------------------------------------------------------------------
`acons' key datum alist => new-alist
Arguments and Values::
......................
key--an object.
datum--an object.
alist--an association list.
new-alist--an association list.
Description::
.............
Creates a fresh cons, the cdr of which is alist and the car of which is
another fresh cons, the car of which is key and the cdr of which is datum.
Examples::
..........
(setq alist '()) => NIL
(acons 1 "one" alist) => ((1 . "one"))
alist => NIL
(setq alist (acons 1 "one" (acons 2 "two" alist))) => ((1 . "one") (2 . "two"))
(assoc 1 alist) => (1 . "one")
(setq alist (acons 1 "uno" alist)) => ((1 . "uno") (1 . "one") (2 . "two"))
(assoc 1 alist) => (1 . "uno")
See Also::
..........
*Note assoc; assoc-if; assoc-if-not:: , *Note pairlis::
Notes::
.......
(acons key datum alist) == (cons (cons key datum) alist)
File: gcl.info, Node: assoc, Next: copy-alist, Prev: acons, Up: Conses Dictionary
assoc, assoc-if, assoc-if-not [Function]
---------------------------------------------------------------------------
`assoc' item alist &key key test test-not => entry
`assoc-if' predicate alist &key key => entry
`assoc-if-not' predicate alist &key key => entry
Arguments and Values::
......................
item--an object.
alist--an association list.
predicate--a designator for a function of one argument that returns a
generalized boolean.
test--a designator for a function of two arguments that returns a
generalized boolean.
test-not--a designator for a function of two arguments that returns a
generalized boolean.
key--a designator for a function of one argument, or nil.
entry--a cons that is an element of alist, or nil.
Description::
.............
assoc, assoc-if, and assoc-if-not return the first cons in alist whose car
satisfies the test, or nil if no such cons is found.
For assoc, assoc-if, and assoc-if-not, if nil appears in alist in place of
a pair, it is ignored.
Examples::
..........
(setq values '((x . 100) (y . 200) (z . 50))) => ((X . 100) (Y . 200) (Z . 50))
(assoc 'y values) => (Y . 200)
(rplacd (assoc 'y values) 201) => (Y . 201)
(assoc 'y values) => (Y . 201)
(setq alist '((1 . "one")(2 . "two")(3 . "three")))
=> ((1 . "one") (2 . "two") (3 . "three"))
(assoc 2 alist) => (2 . "two")
(assoc-if #'evenp alist) => (2 . "two")
(assoc-if-not #'(lambda(x) (< x 3)) alist) => (3 . "three")
(setq alist '(("one" . 1)("two" . 2))) => (("one" . 1) ("two" . 2))
(assoc "one" alist) => NIL
(assoc "one" alist :test #'equalp) => ("one" . 1)
(assoc "two" alist :key #'(lambda(x) (char x 2))) => NIL
(assoc #\o alist :key #'(lambda(x) (char x 2))) => ("two" . 2)
(assoc 'r '((a . b) (c . d) (r . x) (s . y) (r . z))) => (R . X)
(assoc 'goo '((foo . bar) (zoo . goo))) => NIL
(assoc '2 '((1 a b c) (2 b c d) (-7 x y z))) => (2 B C D)
(setq alist '(("one" . 1) ("2" . 2) ("three" . 3)))
=> (("one" . 1) ("2" . 2) ("three" . 3))
(assoc-if-not #'alpha-char-p alist
:key #'(lambda (x) (char x 0))) => ("2" . 2)
Exceptional Situations::
........................
Should be prepared to signal an error of type type-error if alist is not
an association list.
See Also::
..........
*Note rassoc; rassoc-if; rassoc-if-not:: , *Note find; find-if;
find-if-not:: , *Note member; member-if; member-if-not:: , *Note position;
position-if; position-if-not:: ,
*Note Traversal Rules and Side Effects::
Notes::
.......
The :test-not parameter is deprecated.
The function assoc-if-not is deprecated.
It is possible to rplacd the result of assoc, provided that it is not nil,
in order to "update" alist.
The two expressions
(assoc item list :test fn)
and
(find item list :test fn :key #'car)
are equivalent in meaning with one exception: if nil appears in alist in
place of a pair, and item is nil, find will compute the car of the nil in
alist, find that it is equal to item, and return nil, whereas assoc will
ignore the nil in alist and continue to search for an actual cons whose
car is nil.
File: gcl.info, Node: copy-alist, Next: pairlis, Prev: assoc, Up: Conses Dictionary
copy-alist [Function]
---------------------------------------------------------------------------
`copy-alist' alist => new-alist
Arguments and Values::
......................
alist--an association list.
new-alist--an association list.
Description::
.............
copy-alist returns a copy of alist.
The list structure of alist is copied, and the elements of alist which are
conses are also copied (as conses only). Any other objects which are
referred to, whether directly or indirectly, by the alist continue to be
shared.
Examples::
..........
(defparameter *alist* (acons 1 "one" (acons 2 "two" '())))
*alist* => ((1 . "one") (2 . "two"))
(defparameter *list-copy* (copy-list *alist*))
*list-copy* => ((1 . "one") (2 . "two"))
(defparameter *alist-copy* (copy-alist *alist*))
*alist-copy* => ((1 . "one") (2 . "two"))
(setf (cdr (assoc 2 *alist-copy*)) "deux") => "deux"
*alist-copy* => ((1 . "one") (2 . "deux"))
*alist* => ((1 . "one") (2 . "two"))
(setf (cdr (assoc 1 *list-copy*)) "uno") => "uno"
*list-copy* => ((1 . "uno") (2 . "two"))
*alist* => ((1 . "uno") (2 . "two"))
See Also::
..........
*Note copy-list::
File: gcl.info, Node: pairlis, Next: rassoc, Prev: copy-alist, Up: Conses Dictionary
pairlis [Function]
---------------------------------------------------------------------------
`pairlis' keys data &optional alist => new-alist
Arguments and Values::
......................
keys--a proper list.
data--a proper list.
alist--an association list. The default is the empty list.
new-alist--an association list.
Description::
.............
Returns an association list that associates elements of keys to
corresponding elements of data. The consequences are undefined if keys
and data are not of the same length.
If alist is supplied, pairlis returns a modified alist with the new pairs
prepended to it. The new pairs may appear in the resulting association
list in either forward or backward order. The result of
(pairlis '(one two) '(1 2) '((three . 3) (four . 19)))
might be
((one . 1) (two . 2) (three . 3) (four . 19))
or
((two . 2) (one . 1) (three . 3) (four . 19))
Examples::
..........
(setq keys '(1 2 3)
data '("one" "two" "three")
alist '((4 . "four"))) => ((4 . "four"))
(pairlis keys data) => ((3 . "three") (2 . "two") (1 . "one"))
(pairlis keys data alist)
=> ((3 . "three") (2 . "two") (1 . "one") (4 . "four"))
alist => ((4 . "four"))
Exceptional Situations::
........................
Should be prepared to signal an error of type type-error if keys and data
are not proper lists.
See Also::
..........
*Note acons::
File: gcl.info, Node: rassoc, Next: get-properties, Prev: pairlis, Up: Conses Dictionary
rassoc, rassoc-if, rassoc-if-not [Function]
---------------------------------------------------------------------------
`rassoc' item alist &key key test test-not => entry
`rassoc-if' predicate alist &key key => entry
`rassoc-if-not' predicate alist &key key => entry
Arguments and Values::
......................
item--an object.
alist--an association list.
predicate--a designator for a function of one argument that returns a
generalized boolean.
test--a designator for a function of two arguments that returns a
generalized boolean.
test-not--a designator for a function of two arguments that returns a
generalized boolean.
key--a designator for a function of one argument, or nil.
entry--a cons that is an element of the alist, or nil.
Description::
.............
rassoc, rassoc-if, and rassoc-if-not return the first cons whose cdr
satisfies the test. If no such cons is found, nil is returned.
If nil appears in alist in place of a pair, it is ignored.
Examples::
..........
(setq alist '((1 . "one") (2 . "two") (3 . 3)))
=> ((1 . "one") (2 . "two") (3 . 3))
(rassoc 3 alist) => (3 . 3)
(rassoc "two" alist) => NIL
(rassoc "two" alist :test 'equal) => (2 . "two")
(rassoc 1 alist :key #'(lambda (x) (if (numberp x) (/ x 3)))) => (3 . 3)
(rassoc 'a '((a . b) (b . c) (c . a) (z . a))) => (C . A)
(rassoc-if #'stringp alist) => (1 . "one")
(rassoc-if-not #'vectorp alist) => (3 . 3)
See Also::
..........
*Note assoc; assoc-if; assoc-if-not:: ,
*Note Traversal Rules and Side Effects::
Notes::
.......
The :test-not parameter is deprecated.
The function rassoc-if-not is deprecated.
It is possible to rplaca the result of rassoc, provided that it is not
nil, in order to "update" alist.
The expressions
(rassoc item list :test fn)
and
(find item list :test fn :key #'cdr)
are equivalent in meaning, except when the item is nil and nil appears in
place of a pair in the alist. See the function assoc.
File: gcl.info, Node: get-properties, Next: getf, Prev: rassoc, Up: Conses Dictionary
get-properties [Function]
---------------------------------------------------------------------------
`get-properties' plist indicator-list => indicator, value, tail
Arguments and Values::
......................
plist--a property list.
indicator-list--a proper list (of indicators).
indicator--an object that is an element of indicator-list.
value--an object.
tail--a list.
Description::
.............
get-properties is used to look up any of several property list entries all
at once.
It searches the plist for the first entry whose indicator is identical to
one of the objects in indicator-list. If such an entry is found, the
indicator and value returned are the property indicator and its associated
property value, and the tail returned is the tail of the plist that begins
with the found entry (i.e., whose car is the indicator). If no such entry
is found, the indicator, value, and tail are all nil.
Examples::
..........
(setq x '()) => NIL
(setq *indicator-list* '(prop1 prop2)) => (PROP1 PROP2)
(getf x 'prop1) => NIL
(setf (getf x 'prop1) 'val1) => VAL1
(eq (getf x 'prop1) 'val1) => true
(get-properties x *indicator-list*) => PROP1, VAL1, (PROP1 VAL1)
x => (PROP1 VAL1)
See Also::
..........
*Note get:: , *Note getf::
File: gcl.info, Node: getf, Next: remf, Prev: get-properties, Up: Conses Dictionary
getf [Accessor]
---------------------------------------------------------------------------
`getf' plist indicator &optional default => value
(setf (` getf' place indicator &optional default) new-value)
Arguments and Values::
......................
plist--a property list.
place--a place, the value of which is a property list.
indicator--an object.
default--an object. The default is nil.
value--an object.
new-value--an object.
Description::
.............
getf finds a property on the plist whose property indicator is identical
to indicator, and returns its corresponding property value.
If there are multiple properties_1 with that property indicator, getf uses
the first such property.
If there is no property with that property indicator, default is returned.
setf of getf may be used to associate a new object with an existing
indicator in the property list held by place, or to create a new
assocation if none exists.
If there are multiple properties_1 with that property indicator, setf of
getf associates the new-value with the first such property.
When a getf form is used as a setf place, any default which is supplied is
evaluated according to normal left-to-right evaluation rules, but its
value is ignored.
setf of getf is permitted to either write the value of place itself, or
modify of any part, car or cdr, of the list structure held by place.
Examples::
..........
(setq x '()) => NIL
(getf x 'prop1) => NIL
(getf x 'prop1 7) => 7
(getf x 'prop1) => NIL
(setf (getf x 'prop1) 'val1) => VAL1
(eq (getf x 'prop1) 'val1) => true
(getf x 'prop1) => VAL1
(getf x 'prop1 7) => VAL1
x => (PROP1 VAL1)
;; Examples of implementation variation permitted.
(setq foo (list 'a 'b 'c 'd 'e 'f)) => (A B C D E F)
(setq bar (cddr foo)) => (C D E F)
(remf foo 'c) => true
foo => (A B E F)
bar
=> (C D E F)
OR=> (C)
OR=> (NIL)
OR=> (C NIL)
OR=> (C D)
See Also::
..........
*Note get:: , *Note get-properties:: , *Note setf; psetf:: , *Note
Function Call Forms as Places::
Notes::
.......
There is no way (using getf) to distinguish an absent property from one
whose value is default; but see get-properties.
Note that while supplying a default argument to getf in a setf situation
is sometimes not very interesting, it is still important because some
macros, such as push and incf, require a place argument which data is both
read from and written to. In such a context, if a default argument is to
be supplied for the read situation, it must be syntactically valid for the
write situation as well. For example,
(let ((plist '()))
(incf (getf plist 'count 0))
plist) => (COUNT 1)
File: gcl.info, Node: remf, Next: intersection, Prev: getf, Up: Conses Dictionary
remf [Macro]
---------------------------------------------------------------------------
`remf' place indicator => generalized-boolean
Arguments and Values::
......................
place--a place.
indicator--an object.
generalized-boolean--a generalized boolean.
Description::
.............
remf removes from the property list stored in place a property_1 with a
property indicator identical to indicator.
If there are multiple properties_1 with the identical key, remf only
removes the first such property.
remf returns false if no such property was found, or true if a property
was found.
The property indicator and the corresponding property value are removed in
an undefined order by destructively splicing the property list.
remf is permitted to either setf place or to setf any part, car or cdr, of
the list structure held by that place.
For information about the evaluation of subforms of place, see *Note
Evaluation of Subforms to Places::.
Examples::
..........
(setq x (cons () ())) => (NIL)
(setf (getf (car x) 'prop1) 'val1) => VAL1
(remf (car x) 'prop1) => true
(remf (car x) 'prop1) => false
Side Effects::
..............
The property list stored in place is modified.
See Also::
..........
*Note remprop:: , *Note getf::
File: gcl.info, Node: intersection, Next: adjoin, Prev: remf, Up: Conses Dictionary
intersection, nintersection [Function]
---------------------------------------------------------------------------
`intersection' list-1 list-2 &key key test test-not => result-list
`nintersection' list-1 list-2 &key key test test-not => result-list
Arguments and Values::
......................
list-1--a proper list.
list-2--a proper list.
test--a designator for a function of two arguments that returns a
generalized boolean.
test-not--a designator for a function of two arguments that returns a
generalized boolean.
key--a designator for a function of one argument, or nil.
result-list--a list.
Description::
.............
intersection and nintersection return a list that contains every element
that occurs in both list-1 and list-2.
nintersection is the destructive version of intersection. It performs the
same operation, but may destroy list-1 using its cells to construct the
result.
list-2 is not destroyed.
The intersection operation is described as follows. For all possible
ordered pairs consisting of one element from list-1 and one element from
list-2, :test or :test-not are used to determine whether they satisfy the
test. The first argument to the :test or :test-not function is an element
of list-1; the second argument is an element of list-2. If :test or
:test-not is not supplied, eql is used. It is an error if :test and
:test-not are supplied in the same function call.
If :key is supplied (and not nil), it is used to extract the part to be
tested from the list element. The argument to the :key function is an
element of either list-1 or list-2; the :key function typically returns
part of the supplied element. If :key is not supplied or nil, the list-1
and list-2 elements are used.
For every pair that satifies the test, exactly one of the two elements of
the pair will be put in the result. No element from either list appears
in the result that does not satisfy the test for an element from the other
list. If one of the lists contains duplicate elements, there may be
duplication in the result.
There is no guarantee that the order of elements in the result will
reflect the ordering of the arguments in any particular way. The result
list may share cells with, or be eq to, either list-1 or list-2 if
appropriate.
Examples::
..........
(setq list1 (list 1 1 2 3 4 a b c "A" "B" "C" "d")
list2 (list 1 4 5 b c d "a" "B" "c" "D"))
=> (1 4 5 B C D "a" "B" "c" "D")
(intersection list1 list2) => (C B 4 1 1)
(intersection list1 list2 :test 'equal) => ("B" C B 4 1 1)
(intersection list1 list2 :test #'equalp) => ("d" "C" "B" "A" C B 4 1 1)
(nintersection list1 list2) => (1 1 4 B C)
list1 => implementation-dependent ;e.g., (1 1 4 B C)
list2 => implementation-dependent ;e.g., (1 4 5 B C D "a" "B" "c" "D")
(setq list1 (copy-list '((1 . 2) (2 . 3) (3 . 4) (4 . 5))))
=> ((1 . 2) (2 . 3) (3 . 4) (4 . 5))
(setq list2 (copy-list '((1 . 3) (2 . 4) (3 . 6) (4 . 8))))
=> ((1 . 3) (2 . 4) (3 . 6) (4 . 8))
(nintersection list1 list2 :key #'cdr) => ((2 . 3) (3 . 4))
list1 => implementation-dependent ;e.g., ((1 . 2) (2 . 3) (3 . 4))
list2 => implementation-dependent ;e.g., ((1 . 3) (2 . 4) (3 . 6) (4 . 8))
Side Effects::
..............
nintersection can modify list-1,
but not list-2.
Exceptional Situations::
........................
Should be prepared to signal an error of type type-error if list-1 and
list-2 are not proper lists.
See Also::
..........
*Note union; nunion:: ,
*Note Compiler Terminology::,
*Note Traversal Rules and Side Effects::
Notes::
.......
The :test-not parameter is deprecated.
Since the nintersection side effect is not required, it should not be used
in for-effect-only positions in portable code.
File: gcl.info, Node: adjoin, Next: pushnew, Prev: intersection, Up: Conses Dictionary
adjoin [Function]
---------------------------------------------------------------------------
`adjoin' item list &key key test test-not => new-list
Arguments and Values::
......................
item--an object.
list--a proper list.
test--a designator for a function of two arguments that returns a
generalized boolean.
test-not--a designator for a function of two arguments that returns a
generalized boolean.
key--a designator for a function of one argument, or nil.
new-list--a list.
Description::
.............
Tests whether item is the same as an existing element of list. If the
item is not an existing element, adjoin adds it to list (as if by cons)
and returns the resulting list; otherwise, nothing is added and the
original list is returned.
The test, test-not, and key affect how it is determined whether item is
the same as an element of list. For details, see *Note Satisfying a
Two-Argument Test::.\ifvmode\else\endgraf \ifdim \prevdepth>-1000pt
\NIS\parskip \normalparskip\relax\fi
Examples::
..........
(setq slist '()) => NIL
(adjoin 'a slist) => (A)
slist => NIL
(setq slist (adjoin '(test-item 1) slist)) => ((TEST-ITEM 1))
(adjoin '(test-item 1) slist) => ((TEST-ITEM 1) (TEST-ITEM 1))
(adjoin '(test-item 1) slist :test 'equal) => ((TEST-ITEM 1))
(adjoin '(new-test-item 1) slist :key #'cadr) => ((TEST-ITEM 1))
(adjoin '(new-test-item 1) slist) => ((NEW-TEST-ITEM 1) (TEST-ITEM 1))
Exceptional Situations::
........................
Should be prepared to signal an error of type type-error if list is not a
proper list.
See Also::
..........
*Note pushnew:: ,
*Note Traversal Rules and Side Effects::
Notes::
.......
The :test-not parameter is deprecated.
(adjoin item list :key fn)
== (if (member (fn item) list :key fn) list (cons item list))
File: gcl.info, Node: pushnew, Next: set-difference, Prev: adjoin, Up: Conses Dictionary
pushnew [Macro]
---------------------------------------------------------------------------
`pushnew' item place &key key test test-not
=> new-place-value
Arguments and Values::
......................
item--an object.
place--a place, the value of which is a proper list.
test--a designator for a function of two arguments that returns a
generalized boolean.
test-not--a designator for a function of two arguments that returns a
generalized boolean.
key--a designator for a function of one argument, or nil.
new-place-value--a list (the new value of place).
Description::
.............
pushnew tests whether item is the same as any existing element of the
list stored in place. If item is not, it is prepended to the list, and
the new list is stored in place.
pushnew returns the new list that is stored in place.
Whether or not item is already a member of the list that is in place is
determined by comparisons using :test or :test-not. The first argument to
the :test or :test-not function is item; the second argument is an element
of the list in place as returned by the :key function (if supplied).
If :key is supplied, it is used to extract the part to be tested from both
item and the list element, as for adjoin.
The argument to the :key function is an element of the list stored in
place. The :key function typically returns part part of the element of the
list. If :key is not supplied or nil, the list element is used.
For information about the evaluation of subforms of place, see *Note
Evaluation of Subforms to Places::.
It is implementation-dependent whether or not pushnew actually executes
the storing form for its place in the situation where the item is already