1 ;;; cl-seq.el --- Common Lisp features, part 3
3 ;; Copyright (C) 1993, 2001, 2002, 2003, 2004, 2005, 2006, 2007,
4 ;; 2008, 2009, 2010 Free Software Foundation, Inc.
6 ;; Author: Dave Gillespie <daveg@synaptics.com>
8 ;; Keywords: extensions
11 ;; This file is part of GNU Emacs.
13 ;; GNU Emacs is free software: you can redistribute it and/or modify
14 ;; it under the terms of the GNU General Public License as published by
15 ;; the Free Software Foundation, either version 3 of the License, or
16 ;; (at your option) any later version.
18 ;; GNU Emacs is distributed in the hope that it will be useful,
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 ;; GNU General Public License for more details.
23 ;; You should have received a copy of the GNU General Public License
24 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
28 ;; These are extensions to Emacs Lisp that provide a degree of
29 ;; Common Lisp compatibility, beyond what is already built-in
32 ;; This package was written by Dave Gillespie; it is a complete
33 ;; rewrite of Cesar Quiroz's original cl.el package of December 1986.
35 ;; Bug reports, comments, and suggestions are welcome!
37 ;; This file contains the Common Lisp sequence and list functions
38 ;; which take keyword arguments.
40 ;; See cl.el for Change Log.
47 ;;; Keyword parsing. This is special-cased here so that we can compile
48 ;;; this file independent from cl-macs.
50 (defmacro cl-parsing-keywords
(kwords other-keys
&rest body
)
51 (declare (indent 2) (debug (sexp sexp
&rest form
)))
57 (let* ((var (if (consp x
) (car x
) x
))
58 (mem (list 'car
(list 'cdr
(list 'memq
(list 'quote var
)
60 (if (eq var
:test-not
)
61 (setq mem
(list 'and mem
(list 'setq
'cl-test mem
) t
)))
63 (setq mem
(list 'and mem
(list 'setq
'cl-if mem
) t
)))
65 (format "cl-%s" (substring (symbol-name var
) 1)))
66 (if (consp x
) (list 'or mem
(car (cdr x
))) mem
)))))
69 (and (not (eq other-keys t
))
71 (list 'let
'((cl-keys-temp cl-keys
))
72 (list 'while
'cl-keys-temp
73 (list 'or
(list 'memq
'(car cl-keys-temp
)
82 '(car (cdr (memq (quote :allow-other-keys
)
84 '(error "Bad keyword argument %s"
86 '(setq cl-keys-temp
(cdr (cdr cl-keys-temp
)))))))
89 (defmacro cl-check-key
(x)
90 (declare (debug edebug-forms
))
91 (list 'if
'cl-key
(list 'funcall
'cl-key x
) x
))
93 (defmacro cl-check-test-nokey
(item x
)
94 (declare (debug edebug-forms
))
97 (list 'eq
(list 'not
(list 'funcall
'cl-test item x
))
100 (list 'eq
(list 'not
(list 'funcall
'cl-if x
)) 'cl-if-not
))
101 (list 't
(list 'if
(list 'numberp item
)
102 (list 'equal item x
) (list 'eq item x
)))))
104 (defmacro cl-check-test
(item x
)
105 (declare (debug edebug-forms
))
106 (list 'cl-check-test-nokey item
(list 'cl-check-key x
)))
108 (defmacro cl-check-match
(x y
)
109 (declare (debug edebug-forms
))
110 (setq x
(list 'cl-check-key x
) y
(list 'cl-check-key y
))
112 (list 'eq
(list 'not
(list 'funcall
'cl-test x y
)) 'cl-test-not
)
113 (list 'if
(list 'numberp x
)
114 (list 'equal x y
) (list 'eq x y
))))
116 (defvar cl-test
) (defvar cl-test-not
)
117 (defvar cl-if
) (defvar cl-if-not
)
122 (defun reduce (cl-func cl-seq
&rest cl-keys
)
123 "Reduce two-argument FUNCTION across SEQ.
124 \nKeywords supported: :start :end :from-end :initial-value :key
125 \n(fn FUNCTION SEQ [KEYWORD VALUE]...)"
126 (cl-parsing-keywords (:from-end
(:start
0) :end
:initial-value
:key
) ()
127 (or (listp cl-seq
) (setq cl-seq
(append cl-seq nil
)))
128 (setq cl-seq
(subseq cl-seq cl-start cl-end
))
129 (if cl-from-end
(setq cl-seq
(nreverse cl-seq
)))
130 (let ((cl-accum (cond ((memq :initial-value cl-keys
) cl-initial-value
)
131 (cl-seq (cl-check-key (pop cl-seq
)))
132 (t (funcall cl-func
)))))
135 (setq cl-accum
(funcall cl-func
(cl-check-key (pop cl-seq
))
138 (setq cl-accum
(funcall cl-func cl-accum
139 (cl-check-key (pop cl-seq
))))))
143 (defun fill (seq item
&rest cl-keys
)
144 "Fill the elements of SEQ with ITEM.
145 \nKeywords supported: :start :end
146 \n(fn SEQ ITEM [KEYWORD VALUE]...)"
147 (cl-parsing-keywords ((:start
0) :end
) ()
149 (let ((p (nthcdr cl-start seq
))
150 (n (if cl-end
(- cl-end cl-start
) 8000000)))
151 (while (and p
(>= (setq n
(1- n
)) 0))
154 (or cl-end
(setq cl-end
(length seq
)))
155 (if (and (= cl-start
0) (= cl-end
(length seq
)))
157 (while (< cl-start cl-end
)
158 (aset seq cl-start item
)
159 (setq cl-start
(1+ cl-start
)))))
163 (defun replace (cl-seq1 cl-seq2
&rest cl-keys
)
164 "Replace the elements of SEQ1 with the elements of SEQ2.
165 SEQ1 is destructively modified, then returned.
166 \nKeywords supported: :start1 :end1 :start2 :end2
167 \n(fn SEQ1 SEQ2 [KEYWORD VALUE]...)"
168 (cl-parsing-keywords ((:start1
0) :end1
(:start2
0) :end2
) ()
169 (if (and (eq cl-seq1 cl-seq2
) (<= cl-start2 cl-start1
))
170 (or (= cl-start1 cl-start2
)
171 (let* ((cl-len (length cl-seq1
))
172 (cl-n (min (- (or cl-end1 cl-len
) cl-start1
)
173 (- (or cl-end2 cl-len
) cl-start2
))))
174 (while (>= (setq cl-n
(1- cl-n
)) 0)
175 (cl-set-elt cl-seq1
(+ cl-start1 cl-n
)
176 (elt cl-seq2
(+ cl-start2 cl-n
))))))
178 (let ((cl-p1 (nthcdr cl-start1 cl-seq1
))
179 (cl-n1 (if cl-end1
(- cl-end1 cl-start1
) 4000000)))
181 (let ((cl-p2 (nthcdr cl-start2 cl-seq2
))
183 (if cl-end2
(- cl-end2 cl-start2
) 4000000))))
184 (while (and cl-p1 cl-p2
(>= (setq cl-n
(1- cl-n
)) 0))
185 (setcar cl-p1
(car cl-p2
))
186 (setq cl-p1
(cdr cl-p1
) cl-p2
(cdr cl-p2
))))
187 (setq cl-end2
(min (or cl-end2
(length cl-seq2
))
188 (+ cl-start2 cl-n1
)))
189 (while (and cl-p1
(< cl-start2 cl-end2
))
190 (setcar cl-p1
(aref cl-seq2 cl-start2
))
191 (setq cl-p1
(cdr cl-p1
) cl-start2
(1+ cl-start2
)))))
192 (setq cl-end1
(min (or cl-end1
(length cl-seq1
))
193 (+ cl-start1
(- (or cl-end2
(length cl-seq2
))
196 (let ((cl-p2 (nthcdr cl-start2 cl-seq2
)))
197 (while (< cl-start1 cl-end1
)
198 (aset cl-seq1 cl-start1
(car cl-p2
))
199 (setq cl-p2
(cdr cl-p2
) cl-start1
(1+ cl-start1
))))
200 (while (< cl-start1 cl-end1
)
201 (aset cl-seq1 cl-start1
(aref cl-seq2 cl-start2
))
202 (setq cl-start2
(1+ cl-start2
) cl-start1
(1+ cl-start1
))))))
206 (defun remove* (cl-item cl-seq
&rest cl-keys
)
207 "Remove all occurrences of ITEM in SEQ.
208 This is a non-destructive function; it makes a copy of SEQ if necessary
209 to avoid corrupting the original SEQ.
210 \nKeywords supported: :test :test-not :key :count :start :end :from-end
211 \n(fn ITEM SEQ [KEYWORD VALUE]...)"
212 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
:count
:from-end
214 (if (<= (or cl-count
(setq cl-count
8000000)) 0)
216 (if (or (nlistp cl-seq
) (and cl-from-end
(< cl-count
4000000)))
217 (let ((cl-i (cl-position cl-item cl-seq cl-start cl-end
220 (let ((cl-res (apply 'delete
* cl-item
(append cl-seq nil
)
221 (append (if cl-from-end
222 (list :end
(1+ cl-i
))
225 (if (listp cl-seq
) cl-res
226 (if (stringp cl-seq
) (concat cl-res
) (vconcat cl-res
))))
228 (setq cl-end
(- (or cl-end
8000000) cl-start
))
230 (while (and cl-seq
(> cl-end
0)
231 (cl-check-test cl-item
(car cl-seq
))
232 (setq cl-end
(1- cl-end
) cl-seq
(cdr cl-seq
))
233 (> (setq cl-count
(1- cl-count
)) 0))))
234 (if (and (> cl-count
0) (> cl-end
0))
235 (let ((cl-p (if (> cl-start
0) (nthcdr cl-start cl-seq
)
236 (setq cl-end
(1- cl-end
)) (cdr cl-seq
))))
237 (while (and cl-p
(> cl-end
0)
238 (not (cl-check-test cl-item
(car cl-p
))))
239 (setq cl-p
(cdr cl-p
) cl-end
(1- cl-end
)))
240 (if (and cl-p
(> cl-end
0))
241 (nconc (ldiff cl-seq cl-p
)
242 (if (= cl-count
1) (cdr cl-p
)
244 (apply 'delete
* cl-item
245 (copy-sequence (cdr cl-p
))
246 :start
0 :end
(1- cl-end
)
247 :count
(1- cl-count
) cl-keys
))))
252 (defun remove-if (cl-pred cl-list
&rest cl-keys
)
253 "Remove all items satisfying PREDICATE in SEQ.
254 This is a non-destructive function; it makes a copy of SEQ if necessary
255 to avoid corrupting the original SEQ.
256 \nKeywords supported: :key :count :start :end :from-end
257 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
258 (apply 'remove
* nil cl-list
:if cl-pred cl-keys
))
261 (defun remove-if-not (cl-pred cl-list
&rest cl-keys
)
262 "Remove all items not satisfying PREDICATE in SEQ.
263 This is a non-destructive function; it makes a copy of SEQ if necessary
264 to avoid corrupting the original SEQ.
265 \nKeywords supported: :key :count :start :end :from-end
266 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
267 (apply 'remove
* nil cl-list
:if-not cl-pred cl-keys
))
270 (defun delete* (cl-item cl-seq
&rest cl-keys
)
271 "Remove all occurrences of ITEM in SEQ.
272 This is a destructive function; it reuses the storage of SEQ whenever possible.
273 \nKeywords supported: :test :test-not :key :count :start :end :from-end
274 \n(fn ITEM SEQ [KEYWORD VALUE]...)"
275 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
:count
:from-end
277 (if (<= (or cl-count
(setq cl-count
8000000)) 0)
280 (if (and cl-from-end
(< cl-count
4000000))
282 (while (and (>= (setq cl-count
(1- cl-count
)) 0)
283 (setq cl-i
(cl-position cl-item cl-seq cl-start
284 cl-end cl-from-end
)))
285 (if (= cl-i
0) (setq cl-seq
(cdr cl-seq
))
286 (let ((cl-tail (nthcdr (1- cl-i
) cl-seq
)))
287 (setcdr cl-tail
(cdr (cdr cl-tail
)))))
290 (setq cl-end
(- (or cl-end
8000000) cl-start
))
295 (cl-check-test cl-item
(car cl-seq
))
296 (setq cl-end
(1- cl-end
) cl-seq
(cdr cl-seq
))
297 (> (setq cl-count
(1- cl-count
)) 0)))
298 (setq cl-end
(1- cl-end
)))
299 (setq cl-start
(1- cl-start
)))
300 (if (and (> cl-count
0) (> cl-end
0))
301 (let ((cl-p (nthcdr cl-start cl-seq
)))
302 (while (and (cdr cl-p
) (> cl-end
0))
303 (if (cl-check-test cl-item
(car (cdr cl-p
)))
305 (setcdr cl-p
(cdr (cdr cl-p
)))
306 (if (= (setq cl-count
(1- cl-count
)) 0)
308 (setq cl-p
(cdr cl-p
)))
309 (setq cl-end
(1- cl-end
)))))
311 (apply 'remove
* cl-item cl-seq cl-keys
)))))
314 (defun delete-if (cl-pred cl-list
&rest cl-keys
)
315 "Remove all items satisfying PREDICATE in SEQ.
316 This is a destructive function; it reuses the storage of SEQ whenever possible.
317 \nKeywords supported: :key :count :start :end :from-end
318 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
319 (apply 'delete
* nil cl-list
:if cl-pred cl-keys
))
322 (defun delete-if-not (cl-pred cl-list
&rest cl-keys
)
323 "Remove all items not satisfying PREDICATE in SEQ.
324 This is a destructive function; it reuses the storage of SEQ whenever possible.
325 \nKeywords supported: :key :count :start :end :from-end
326 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
327 (apply 'delete
* nil cl-list
:if-not cl-pred cl-keys
))
330 (defun remove-duplicates (cl-seq &rest cl-keys
)
331 "Return a copy of SEQ with all duplicate elements removed.
332 \nKeywords supported: :test :test-not :key :start :end :from-end
333 \n(fn SEQ [KEYWORD VALUE]...)"
334 (cl-delete-duplicates cl-seq cl-keys t
))
337 (defun delete-duplicates (cl-seq &rest cl-keys
)
338 "Remove all duplicate elements from SEQ (destructively).
339 \nKeywords supported: :test :test-not :key :start :end :from-end
340 \n(fn SEQ [KEYWORD VALUE]...)"
341 (cl-delete-duplicates cl-seq cl-keys nil
))
343 (defun cl-delete-duplicates (cl-seq cl-keys cl-copy
)
345 (cl-parsing-keywords (:test
:test-not
:key
(:start
0) :end
:from-end
:if
)
348 (let ((cl-p (nthcdr cl-start cl-seq
)) cl-i
)
349 (setq cl-end
(- (or cl-end
(length cl-seq
)) cl-start
))
352 (while (setq cl-i
(cl-position (cl-check-key (car cl-p
))
353 (cdr cl-p
) cl-i
(1- cl-end
)))
354 (if cl-copy
(setq cl-seq
(copy-sequence cl-seq
)
355 cl-p
(nthcdr cl-start cl-seq
) cl-copy nil
))
356 (let ((cl-tail (nthcdr cl-i cl-p
)))
357 (setcdr cl-tail
(cdr (cdr cl-tail
))))
358 (setq cl-end
(1- cl-end
)))
359 (setq cl-p
(cdr cl-p
) cl-end
(1- cl-end
)
360 cl-start
(1+ cl-start
)))
362 (setq cl-end
(- (or cl-end
(length cl-seq
)) cl-start
))
363 (while (and (cdr cl-seq
) (= cl-start
0) (> cl-end
1)
364 (cl-position (cl-check-key (car cl-seq
))
365 (cdr cl-seq
) 0 (1- cl-end
)))
366 (setq cl-seq
(cdr cl-seq
) cl-end
(1- cl-end
)))
367 (let ((cl-p (if (> cl-start
0) (nthcdr (1- cl-start
) cl-seq
)
368 (setq cl-end
(1- cl-end
) cl-start
1) cl-seq
)))
369 (while (and (cdr (cdr cl-p
)) (> cl-end
1))
370 (if (cl-position (cl-check-key (car (cdr cl-p
)))
371 (cdr (cdr cl-p
)) 0 (1- cl-end
))
373 (if cl-copy
(setq cl-seq
(copy-sequence cl-seq
)
374 cl-p
(nthcdr (1- cl-start
) cl-seq
)
376 (setcdr cl-p
(cdr (cdr cl-p
))))
377 (setq cl-p
(cdr cl-p
)))
378 (setq cl-end
(1- cl-end
) cl-start
(1+ cl-start
)))
380 (let ((cl-res (cl-delete-duplicates (append cl-seq nil
) cl-keys nil
)))
381 (if (stringp cl-seq
) (concat cl-res
) (vconcat cl-res
)))))
384 (defun substitute (cl-new cl-old cl-seq
&rest cl-keys
)
385 "Substitute NEW for OLD in SEQ.
386 This is a non-destructive function; it makes a copy of SEQ if necessary
387 to avoid corrupting the original SEQ.
388 \nKeywords supported: :test :test-not :key :count :start :end :from-end
389 \n(fn NEW OLD SEQ [KEYWORD VALUE]...)"
390 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
:count
391 (:start
0) :end
:from-end
) ()
392 (if (or (eq cl-old cl-new
)
393 (<= (or cl-count
(setq cl-from-end nil cl-count
8000000)) 0))
395 (let ((cl-i (cl-position cl-old cl-seq cl-start cl-end
)))
398 (setq cl-seq
(copy-sequence cl-seq
))
400 (progn (cl-set-elt cl-seq cl-i cl-new
)
401 (setq cl-i
(1+ cl-i
) cl-count
(1- cl-count
))))
402 (apply 'nsubstitute cl-new cl-old cl-seq
:count cl-count
403 :start cl-i cl-keys
))))))
406 (defun substitute-if (cl-new cl-pred cl-list
&rest cl-keys
)
407 "Substitute NEW for all items satisfying PREDICATE in SEQ.
408 This is a non-destructive function; it makes a copy of SEQ if necessary
409 to avoid corrupting the original SEQ.
410 \nKeywords supported: :key :count :start :end :from-end
411 \n(fn NEW PREDICATE SEQ [KEYWORD VALUE]...)"
412 (apply 'substitute cl-new nil cl-list
:if cl-pred cl-keys
))
415 (defun substitute-if-not (cl-new cl-pred cl-list
&rest cl-keys
)
416 "Substitute NEW for all items not satisfying PREDICATE in SEQ.
417 This is a non-destructive function; it makes a copy of SEQ if necessary
418 to avoid corrupting the original SEQ.
419 \nKeywords supported: :key :count :start :end :from-end
420 \n(fn NEW PREDICATE SEQ [KEYWORD VALUE]...)"
421 (apply 'substitute cl-new nil cl-list
:if-not cl-pred cl-keys
))
424 (defun nsubstitute (cl-new cl-old cl-seq
&rest cl-keys
)
425 "Substitute NEW for OLD in SEQ.
426 This is a destructive function; it reuses the storage of SEQ whenever possible.
427 \nKeywords supported: :test :test-not :key :count :start :end :from-end
428 \n(fn NEW OLD SEQ [KEYWORD VALUE]...)"
429 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
:count
430 (:start
0) :end
:from-end
) ()
431 (or (eq cl-old cl-new
) (<= (or cl-count
(setq cl-count
8000000)) 0)
432 (if (and (listp cl-seq
) (or (not cl-from-end
) (> cl-count
4000000)))
433 (let ((cl-p (nthcdr cl-start cl-seq
)))
434 (setq cl-end
(- (or cl-end
8000000) cl-start
))
435 (while (and cl-p
(> cl-end
0) (> cl-count
0))
436 (if (cl-check-test cl-old
(car cl-p
))
439 (setq cl-count
(1- cl-count
))))
440 (setq cl-p
(cdr cl-p
) cl-end
(1- cl-end
))))
441 (or cl-end
(setq cl-end
(length cl-seq
)))
443 (while (and (< cl-start cl-end
) (> cl-count
0))
444 (setq cl-end
(1- cl-end
))
445 (if (cl-check-test cl-old
(elt cl-seq cl-end
))
447 (cl-set-elt cl-seq cl-end cl-new
)
448 (setq cl-count
(1- cl-count
)))))
449 (while (and (< cl-start cl-end
) (> cl-count
0))
450 (if (cl-check-test cl-old
(aref cl-seq cl-start
))
452 (aset cl-seq cl-start cl-new
)
453 (setq cl-count
(1- cl-count
))))
454 (setq cl-start
(1+ cl-start
))))))
458 (defun nsubstitute-if (cl-new cl-pred cl-list
&rest cl-keys
)
459 "Substitute NEW for all items satisfying PREDICATE in SEQ.
460 This is a destructive function; it reuses the storage of SEQ whenever possible.
461 \nKeywords supported: :key :count :start :end :from-end
462 \n(fn NEW PREDICATE SEQ [KEYWORD VALUE]...)"
463 (apply 'nsubstitute cl-new nil cl-list
:if cl-pred cl-keys
))
466 (defun nsubstitute-if-not (cl-new cl-pred cl-list
&rest cl-keys
)
467 "Substitute NEW for all items not satisfying PREDICATE in SEQ.
468 This is a destructive function; it reuses the storage of SEQ whenever possible.
469 \nKeywords supported: :key :count :start :end :from-end
470 \n(fn NEW PREDICATE SEQ [KEYWORD VALUE]...)"
471 (apply 'nsubstitute cl-new nil cl-list
:if-not cl-pred cl-keys
))
474 (defun find (cl-item cl-seq
&rest cl-keys
)
475 "Find the first occurrence of ITEM in SEQ.
476 Return the matching ITEM, or nil if not found.
477 \nKeywords supported: :test :test-not :key :start :end :from-end
478 \n(fn ITEM SEQ [KEYWORD VALUE]...)"
479 (let ((cl-pos (apply 'position cl-item cl-seq cl-keys
)))
480 (and cl-pos
(elt cl-seq cl-pos
))))
483 (defun find-if (cl-pred cl-list
&rest cl-keys
)
484 "Find the first item satisfying PREDICATE in SEQ.
485 Return the matching item, or nil if not found.
486 \nKeywords supported: :key :start :end :from-end
487 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
488 (apply 'find nil cl-list
:if cl-pred cl-keys
))
491 (defun find-if-not (cl-pred cl-list
&rest cl-keys
)
492 "Find the first item not satisfying PREDICATE in SEQ.
493 Return the matching item, or nil if not found.
494 \nKeywords supported: :key :start :end :from-end
495 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
496 (apply 'find nil cl-list
:if-not cl-pred cl-keys
))
499 (defun position (cl-item cl-seq
&rest cl-keys
)
500 "Find the first occurrence of ITEM in SEQ.
501 Return the index of the matching item, or nil if not found.
502 \nKeywords supported: :test :test-not :key :start :end :from-end
503 \n(fn ITEM SEQ [KEYWORD VALUE]...)"
504 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
505 (:start
0) :end
:from-end
) ()
506 (cl-position cl-item cl-seq cl-start cl-end cl-from-end
)))
508 (defun cl-position (cl-item cl-seq cl-start
&optional cl-end cl-from-end
)
510 (let ((cl-p (nthcdr cl-start cl-seq
)))
511 (or cl-end
(setq cl-end
8000000))
513 (while (and cl-p
(< cl-start cl-end
) (or (not cl-res
) cl-from-end
))
514 (if (cl-check-test cl-item
(car cl-p
))
515 (setq cl-res cl-start
))
516 (setq cl-p
(cdr cl-p
) cl-start
(1+ cl-start
)))
518 (or cl-end
(setq cl-end
(length cl-seq
)))
521 (while (and (>= (setq cl-end
(1- cl-end
)) cl-start
)
522 (not (cl-check-test cl-item
(aref cl-seq cl-end
)))))
523 (and (>= cl-end cl-start
) cl-end
))
524 (while (and (< cl-start cl-end
)
525 (not (cl-check-test cl-item
(aref cl-seq cl-start
))))
526 (setq cl-start
(1+ cl-start
)))
527 (and (< cl-start cl-end
) cl-start
))))
530 (defun position-if (cl-pred cl-list
&rest cl-keys
)
531 "Find the first item satisfying PREDICATE in SEQ.
532 Return the index of the matching item, or nil if not found.
533 \nKeywords supported: :key :start :end :from-end
534 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
535 (apply 'position nil cl-list
:if cl-pred cl-keys
))
538 (defun position-if-not (cl-pred cl-list
&rest cl-keys
)
539 "Find the first item not satisfying PREDICATE in SEQ.
540 Return the index of the matching item, or nil if not found.
541 \nKeywords supported: :key :start :end :from-end
542 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
543 (apply 'position nil cl-list
:if-not cl-pred cl-keys
))
546 (defun count (cl-item cl-seq
&rest cl-keys
)
547 "Count the number of occurrences of ITEM in SEQ.
548 \nKeywords supported: :test :test-not :key :start :end
549 \n(fn ITEM SEQ [KEYWORD VALUE]...)"
550 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
(:start
0) :end
) ()
551 (let ((cl-count 0) cl-x
)
552 (or cl-end
(setq cl-end
(length cl-seq
)))
553 (if (consp cl-seq
) (setq cl-seq
(nthcdr cl-start cl-seq
)))
554 (while (< cl-start cl-end
)
555 (setq cl-x
(if (consp cl-seq
) (pop cl-seq
) (aref cl-seq cl-start
)))
556 (if (cl-check-test cl-item cl-x
) (setq cl-count
(1+ cl-count
)))
557 (setq cl-start
(1+ cl-start
)))
561 (defun count-if (cl-pred cl-list
&rest cl-keys
)
562 "Count the number of items satisfying PREDICATE in SEQ.
563 \nKeywords supported: :key :start :end
564 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
565 (apply 'count nil cl-list
:if cl-pred cl-keys
))
568 (defun count-if-not (cl-pred cl-list
&rest cl-keys
)
569 "Count the number of items not satisfying PREDICATE in SEQ.
570 \nKeywords supported: :key :start :end
571 \n(fn PREDICATE SEQ [KEYWORD VALUE]...)"
572 (apply 'count nil cl-list
:if-not cl-pred cl-keys
))
575 (defun mismatch (cl-seq1 cl-seq2
&rest cl-keys
)
576 "Compare SEQ1 with SEQ2, return index of first mismatching element.
577 Return nil if the sequences match. If one sequence is a prefix of the
578 other, the return value indicates the end of the shorter sequence.
579 \nKeywords supported: :test :test-not :key :start1 :end1 :start2 :end2 :from-end
580 \n(fn SEQ1 SEQ2 [KEYWORD VALUE]...)"
581 (cl-parsing-keywords (:test
:test-not
:key
:from-end
582 (:start1
0) :end1
(:start2
0) :end2
) ()
583 (or cl-end1
(setq cl-end1
(length cl-seq1
)))
584 (or cl-end2
(setq cl-end2
(length cl-seq2
)))
587 (while (and (< cl-start1 cl-end1
) (< cl-start2 cl-end2
)
588 (cl-check-match (elt cl-seq1
(1- cl-end1
))
589 (elt cl-seq2
(1- cl-end2
))))
590 (setq cl-end1
(1- cl-end1
) cl-end2
(1- cl-end2
)))
591 (and (or (< cl-start1 cl-end1
) (< cl-start2 cl-end2
))
593 (let ((cl-p1 (and (listp cl-seq1
) (nthcdr cl-start1 cl-seq1
)))
594 (cl-p2 (and (listp cl-seq2
) (nthcdr cl-start2 cl-seq2
))))
595 (while (and (< cl-start1 cl-end1
) (< cl-start2 cl-end2
)
596 (cl-check-match (if cl-p1
(car cl-p1
)
597 (aref cl-seq1 cl-start1
))
598 (if cl-p2
(car cl-p2
)
599 (aref cl-seq2 cl-start2
))))
600 (setq cl-p1
(cdr cl-p1
) cl-p2
(cdr cl-p2
)
601 cl-start1
(1+ cl-start1
) cl-start2
(1+ cl-start2
)))
602 (and (or (< cl-start1 cl-end1
) (< cl-start2 cl-end2
))
606 (defun search (cl-seq1 cl-seq2
&rest cl-keys
)
607 "Search for SEQ1 as a subsequence of SEQ2.
608 Return the index of the leftmost element of the first match found;
609 return nil if there are no matches.
610 \nKeywords supported: :test :test-not :key :start1 :end1 :start2 :end2 :from-end
611 \n(fn SEQ1 SEQ2 [KEYWORD VALUE]...)"
612 (cl-parsing-keywords (:test
:test-not
:key
:from-end
613 (:start1
0) :end1
(:start2
0) :end2
) ()
614 (or cl-end1
(setq cl-end1
(length cl-seq1
)))
615 (or cl-end2
(setq cl-end2
(length cl-seq2
)))
616 (if (>= cl-start1 cl-end1
)
617 (if cl-from-end cl-end2 cl-start2
)
618 (let* ((cl-len (- cl-end1 cl-start1
))
619 (cl-first (cl-check-key (elt cl-seq1 cl-start1
)))
621 (setq cl-end2
(- cl-end2
(1- cl-len
)))
622 (while (and (< cl-start2 cl-end2
)
623 (setq cl-pos
(cl-position cl-first cl-seq2
624 cl-start2 cl-end2 cl-from-end
))
625 (apply 'mismatch cl-seq1 cl-seq2
626 :start1
(1+ cl-start1
) :end1 cl-end1
627 :start2
(1+ cl-pos
) :end2
(+ cl-pos cl-len
)
628 :from-end nil cl-keys
))
629 (if cl-from-end
(setq cl-end2 cl-pos
) (setq cl-start2
(1+ cl-pos
))))
630 (and (< cl-start2 cl-end2
) cl-pos
)))))
633 (defun sort* (cl-seq cl-pred
&rest cl-keys
)
634 "Sort the argument SEQ according to PREDICATE.
635 This is a destructive function; it reuses the storage of SEQ if possible.
636 \nKeywords supported: :key
637 \n(fn SEQ PREDICATE [KEYWORD VALUE]...)"
639 (replace cl-seq
(apply 'sort
* (append cl-seq nil
) cl-pred cl-keys
))
640 (cl-parsing-keywords (:key
) ()
641 (if (memq cl-key
'(nil identity
))
642 (sort cl-seq cl-pred
)
643 (sort cl-seq
(function (lambda (cl-x cl-y
)
644 (funcall cl-pred
(funcall cl-key cl-x
)
645 (funcall cl-key cl-y
)))))))))
648 (defun stable-sort (cl-seq cl-pred
&rest cl-keys
)
649 "Sort the argument SEQ stably according to PREDICATE.
650 This is a destructive function; it reuses the storage of SEQ if possible.
651 \nKeywords supported: :key
652 \n(fn SEQ PREDICATE [KEYWORD VALUE]...)"
653 (apply 'sort
* cl-seq cl-pred cl-keys
))
656 (defun merge (cl-type cl-seq1 cl-seq2 cl-pred
&rest cl-keys
)
657 "Destructively merge the two sequences to produce a new sequence.
658 TYPE is the sequence type to return, SEQ1 and SEQ2 are the two argument
659 sequences, and PREDICATE is a `less-than' predicate on the elements.
660 \nKeywords supported: :key
661 \n(fn TYPE SEQ1 SEQ2 PREDICATE [KEYWORD VALUE]...)"
662 (or (listp cl-seq1
) (setq cl-seq1
(append cl-seq1 nil
)))
663 (or (listp cl-seq2
) (setq cl-seq2
(append cl-seq2 nil
)))
664 (cl-parsing-keywords (:key
) ()
666 (while (and cl-seq1 cl-seq2
)
667 (if (funcall cl-pred
(cl-check-key (car cl-seq2
))
668 (cl-check-key (car cl-seq1
)))
669 (push (pop cl-seq2
) cl-res
)
670 (push (pop cl-seq1
) cl-res
)))
671 (coerce (nconc (nreverse cl-res
) cl-seq1 cl-seq2
) cl-type
))))
673 ;;; See compiler macro in cl-macs.el
675 (defun member* (cl-item cl-list
&rest cl-keys
)
676 "Find the first occurrence of ITEM in LIST.
677 Return the sublist of LIST whose car is ITEM.
678 \nKeywords supported: :test :test-not :key
679 \n(fn ITEM LIST [KEYWORD VALUE]...)"
681 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
) ()
682 (while (and cl-list
(not (cl-check-test cl-item
(car cl-list
))))
683 (setq cl-list
(cdr cl-list
)))
685 (if (and (numberp cl-item
) (not (integerp cl-item
)))
686 (member cl-item cl-list
)
687 (memq cl-item cl-list
))))
690 (defun member-if (cl-pred cl-list
&rest cl-keys
)
691 "Find the first item satisfying PREDICATE in LIST.
692 Return the sublist of LIST whose car matches.
693 \nKeywords supported: :key
694 \n(fn PREDICATE LIST [KEYWORD VALUE]...)"
695 (apply 'member
* nil cl-list
:if cl-pred cl-keys
))
698 (defun member-if-not (cl-pred cl-list
&rest cl-keys
)
699 "Find the first item not satisfying PREDICATE in LIST.
700 Return the sublist of LIST whose car matches.
701 \nKeywords supported: :key
702 \n(fn PREDICATE LIST [KEYWORD VALUE]...)"
703 (apply 'member
* nil cl-list
:if-not cl-pred cl-keys
))
706 (defun cl-adjoin (cl-item cl-list
&rest cl-keys
)
707 (if (cl-parsing-keywords (:key
) t
708 (apply 'member
* (cl-check-key cl-item
) cl-list cl-keys
))
710 (cons cl-item cl-list
)))
712 ;;; See compiler macro in cl-macs.el
714 (defun assoc* (cl-item cl-alist
&rest cl-keys
)
715 "Find the first item whose car matches ITEM in LIST.
716 \nKeywords supported: :test :test-not :key
717 \n(fn ITEM LIST [KEYWORD VALUE]...)"
719 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
) ()
721 (or (not (consp (car cl-alist
)))
722 (not (cl-check-test cl-item
(car (car cl-alist
))))))
723 (setq cl-alist
(cdr cl-alist
)))
724 (and cl-alist
(car cl-alist
)))
725 (if (and (numberp cl-item
) (not (integerp cl-item
)))
726 (assoc cl-item cl-alist
)
727 (assq cl-item cl-alist
))))
730 (defun assoc-if (cl-pred cl-list
&rest cl-keys
)
731 "Find the first item whose car satisfies PREDICATE in LIST.
732 \nKeywords supported: :key
733 \n(fn PREDICATE LIST [KEYWORD VALUE]...)"
734 (apply 'assoc
* nil cl-list
:if cl-pred cl-keys
))
737 (defun assoc-if-not (cl-pred cl-list
&rest cl-keys
)
738 "Find the first item whose car does not satisfy PREDICATE in LIST.
739 \nKeywords supported: :key
740 \n(fn PREDICATE LIST [KEYWORD VALUE]...)"
741 (apply 'assoc
* nil cl-list
:if-not cl-pred cl-keys
))
744 (defun rassoc* (cl-item cl-alist
&rest cl-keys
)
745 "Find the first item whose cdr matches ITEM in LIST.
746 \nKeywords supported: :test :test-not :key
747 \n(fn ITEM LIST [KEYWORD VALUE]...)"
748 (if (or cl-keys
(numberp cl-item
))
749 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
) ()
751 (or (not (consp (car cl-alist
)))
752 (not (cl-check-test cl-item
(cdr (car cl-alist
))))))
753 (setq cl-alist
(cdr cl-alist
)))
754 (and cl-alist
(car cl-alist
)))
755 (rassq cl-item cl-alist
)))
758 (defun rassoc-if (cl-pred cl-list
&rest cl-keys
)
759 "Find the first item whose cdr satisfies PREDICATE in LIST.
760 \nKeywords supported: :key
761 \n(fn PREDICATE LIST [KEYWORD VALUE]...)"
762 (apply 'rassoc
* nil cl-list
:if cl-pred cl-keys
))
765 (defun rassoc-if-not (cl-pred cl-list
&rest cl-keys
)
766 "Find the first item whose cdr does not satisfy PREDICATE in LIST.
767 \nKeywords supported: :key
768 \n(fn PREDICATE LIST [KEYWORD VALUE]...)"
769 (apply 'rassoc
* nil cl-list
:if-not cl-pred cl-keys
))
772 (defun union (cl-list1 cl-list2
&rest cl-keys
)
773 "Combine LIST1 and LIST2 using a set-union operation.
774 The result list contains all items that appear in either LIST1 or LIST2.
775 This is a non-destructive function; it makes a copy of the data if necessary
776 to avoid corrupting the original LIST1 and LIST2.
777 \nKeywords supported: :test :test-not :key
778 \n(fn LIST1 LIST2 [KEYWORD VALUE]...)"
779 (cond ((null cl-list1
) cl-list2
) ((null cl-list2
) cl-list1
)
780 ((equal cl-list1 cl-list2
) cl-list1
)
782 (or (>= (length cl-list1
) (length cl-list2
))
783 (setq cl-list1
(prog1 cl-list2
(setq cl-list2 cl-list1
))))
785 (if (or cl-keys
(numberp (car cl-list2
)))
786 (setq cl-list1
(apply 'adjoin
(car cl-list2
) cl-list1 cl-keys
))
787 (or (memq (car cl-list2
) cl-list1
)
788 (push (car cl-list2
) cl-list1
)))
793 (defun nunion (cl-list1 cl-list2
&rest cl-keys
)
794 "Combine LIST1 and LIST2 using a set-union operation.
795 The result list contains all items that appear in either LIST1 or LIST2.
796 This is a destructive function; it reuses the storage of LIST1 and LIST2
798 \nKeywords supported: :test :test-not :key
799 \n(fn LIST1 LIST2 [KEYWORD VALUE]...)"
800 (cond ((null cl-list1
) cl-list2
) ((null cl-list2
) cl-list1
)
801 (t (apply 'union cl-list1 cl-list2 cl-keys
))))
804 (defun intersection (cl-list1 cl-list2
&rest cl-keys
)
805 "Combine LIST1 and LIST2 using a set-intersection operation.
806 The result list contains all items that appear in both LIST1 and LIST2.
807 This is a non-destructive function; it makes a copy of the data if necessary
808 to avoid corrupting the original LIST1 and LIST2.
809 \nKeywords supported: :test :test-not :key
810 \n(fn LIST1 LIST2 [KEYWORD VALUE]...)"
811 (and cl-list1 cl-list2
812 (if (equal cl-list1 cl-list2
) cl-list1
813 (cl-parsing-keywords (:key
) (:test
:test-not
)
815 (or (>= (length cl-list1
) (length cl-list2
))
816 (setq cl-list1
(prog1 cl-list2
(setq cl-list2 cl-list1
))))
818 (if (if (or cl-keys
(numberp (car cl-list2
)))
819 (apply 'member
* (cl-check-key (car cl-list2
))
821 (memq (car cl-list2
) cl-list1
))
822 (push (car cl-list2
) cl-res
))
827 (defun nintersection (cl-list1 cl-list2
&rest cl-keys
)
828 "Combine LIST1 and LIST2 using a set-intersection operation.
829 The result list contains all items that appear in both LIST1 and LIST2.
830 This is a destructive function; it reuses the storage of LIST1 and LIST2
832 \nKeywords supported: :test :test-not :key
833 \n(fn LIST1 LIST2 [KEYWORD VALUE]...)"
834 (and cl-list1 cl-list2
(apply 'intersection cl-list1 cl-list2 cl-keys
)))
837 (defun set-difference (cl-list1 cl-list2
&rest cl-keys
)
838 "Combine LIST1 and LIST2 using a set-difference operation.
839 The result list contains all items that appear in LIST1 but not LIST2.
840 This is a non-destructive function; it makes a copy of the data if necessary
841 to avoid corrupting the original LIST1 and LIST2.
842 \nKeywords supported: :test :test-not :key
843 \n(fn LIST1 LIST2 [KEYWORD VALUE]...)"
844 (if (or (null cl-list1
) (null cl-list2
)) cl-list1
845 (cl-parsing-keywords (:key
) (:test
:test-not
)
848 (or (if (or cl-keys
(numberp (car cl-list1
)))
849 (apply 'member
* (cl-check-key (car cl-list1
))
851 (memq (car cl-list1
) cl-list2
))
852 (push (car cl-list1
) cl-res
))
857 (defun nset-difference (cl-list1 cl-list2
&rest cl-keys
)
858 "Combine LIST1 and LIST2 using a set-difference operation.
859 The result list contains all items that appear in LIST1 but not LIST2.
860 This is a destructive function; it reuses the storage of LIST1 and LIST2
862 \nKeywords supported: :test :test-not :key
863 \n(fn LIST1 LIST2 [KEYWORD VALUE]...)"
864 (if (or (null cl-list1
) (null cl-list2
)) cl-list1
865 (apply 'set-difference cl-list1 cl-list2 cl-keys
)))
868 (defun set-exclusive-or (cl-list1 cl-list2
&rest cl-keys
)
869 "Combine LIST1 and LIST2 using a set-exclusive-or operation.
870 The result list contains all items that appear in exactly one of LIST1, LIST2.
871 This is a non-destructive function; it makes a copy of the data if necessary
872 to avoid corrupting the original LIST1 and LIST2.
873 \nKeywords supported: :test :test-not :key
874 \n(fn LIST1 LIST2 [KEYWORD VALUE]...)"
875 (cond ((null cl-list1
) cl-list2
) ((null cl-list2
) cl-list1
)
876 ((equal cl-list1 cl-list2
) nil
)
877 (t (append (apply 'set-difference cl-list1 cl-list2 cl-keys
)
878 (apply 'set-difference cl-list2 cl-list1 cl-keys
)))))
881 (defun nset-exclusive-or (cl-list1 cl-list2
&rest cl-keys
)
882 "Combine LIST1 and LIST2 using a set-exclusive-or operation.
883 The result list contains all items that appear in exactly one of LIST1, LIST2.
884 This is a destructive function; it reuses the storage of LIST1 and LIST2
886 \nKeywords supported: :test :test-not :key
887 \n(fn LIST1 LIST2 [KEYWORD VALUE]...)"
888 (cond ((null cl-list1
) cl-list2
) ((null cl-list2
) cl-list1
)
889 ((equal cl-list1 cl-list2
) nil
)
890 (t (nconc (apply 'nset-difference cl-list1 cl-list2 cl-keys
)
891 (apply 'nset-difference cl-list2 cl-list1 cl-keys
)))))
894 (defun subsetp (cl-list1 cl-list2
&rest cl-keys
)
895 "Return true if LIST1 is a subset of LIST2.
896 I.e., if every element of LIST1 also appears in LIST2.
897 \nKeywords supported: :test :test-not :key
898 \n(fn LIST1 LIST2 [KEYWORD VALUE]...)"
899 (cond ((null cl-list1
) t
) ((null cl-list2
) nil
)
900 ((equal cl-list1 cl-list2
) t
)
901 (t (cl-parsing-keywords (:key
) (:test
:test-not
)
903 (apply 'member
* (cl-check-key (car cl-list1
))
909 (defun subst-if (cl-new cl-pred cl-tree
&rest cl-keys
)
910 "Substitute NEW for elements matching PREDICATE in TREE (non-destructively).
911 Return a copy of TREE with all matching elements replaced by NEW.
912 \nKeywords supported: :key
913 \n(fn NEW PREDICATE TREE [KEYWORD VALUE]...)"
914 (apply 'sublis
(list (cons nil cl-new
)) cl-tree
:if cl-pred cl-keys
))
917 (defun subst-if-not (cl-new cl-pred cl-tree
&rest cl-keys
)
918 "Substitute NEW for elts not matching PREDICATE in TREE (non-destructively).
919 Return a copy of TREE with all non-matching elements replaced by NEW.
920 \nKeywords supported: :key
921 \n(fn NEW PREDICATE TREE [KEYWORD VALUE]...)"
922 (apply 'sublis
(list (cons nil cl-new
)) cl-tree
:if-not cl-pred cl-keys
))
925 (defun nsubst (cl-new cl-old cl-tree
&rest cl-keys
)
926 "Substitute NEW for OLD everywhere in TREE (destructively).
927 Any element of TREE which is `eql' to OLD is changed to NEW (via a call
929 \nKeywords supported: :test :test-not :key
930 \n(fn NEW OLD TREE [KEYWORD VALUE]...)"
931 (apply 'nsublis
(list (cons cl-old cl-new
)) cl-tree cl-keys
))
934 (defun nsubst-if (cl-new cl-pred cl-tree
&rest cl-keys
)
935 "Substitute NEW for elements matching PREDICATE in TREE (destructively).
936 Any element of TREE which matches is changed to NEW (via a call to `setcar').
937 \nKeywords supported: :key
938 \n(fn NEW PREDICATE TREE [KEYWORD VALUE]...)"
939 (apply 'nsublis
(list (cons nil cl-new
)) cl-tree
:if cl-pred cl-keys
))
942 (defun nsubst-if-not (cl-new cl-pred cl-tree
&rest cl-keys
)
943 "Substitute NEW for elements not matching PREDICATE in TREE (destructively).
944 Any element of TREE which matches is changed to NEW (via a call to `setcar').
945 \nKeywords supported: :key
946 \n(fn NEW PREDICATE TREE [KEYWORD VALUE]...)"
947 (apply 'nsublis
(list (cons nil cl-new
)) cl-tree
:if-not cl-pred cl-keys
))
950 (defun sublis (cl-alist cl-tree
&rest cl-keys
)
951 "Perform substitutions indicated by ALIST in TREE (non-destructively).
952 Return a copy of TREE with all matching elements replaced.
953 \nKeywords supported: :test :test-not :key
954 \n(fn ALIST TREE [KEYWORD VALUE]...)"
955 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
) ()
956 (cl-sublis-rec cl-tree
)))
959 (defun cl-sublis-rec (cl-tree) ; uses cl-alist/key/test*/if*
960 (let ((cl-temp (cl-check-key cl-tree
)) (cl-p cl-alist
))
961 (while (and cl-p
(not (cl-check-test-nokey (car (car cl-p
)) cl-temp
)))
962 (setq cl-p
(cdr cl-p
)))
963 (if cl-p
(cdr (car cl-p
))
965 (let ((cl-a (cl-sublis-rec (car cl-tree
)))
966 (cl-d (cl-sublis-rec (cdr cl-tree
))))
967 (if (and (eq cl-a
(car cl-tree
)) (eq cl-d
(cdr cl-tree
)))
973 (defun nsublis (cl-alist cl-tree
&rest cl-keys
)
974 "Perform substitutions indicated by ALIST in TREE (destructively).
975 Any matching element of TREE is changed via a call to `setcar'.
976 \nKeywords supported: :test :test-not :key
977 \n(fn ALIST TREE [KEYWORD VALUE]...)"
978 (cl-parsing-keywords (:test
:test-not
:key
:if
:if-not
) ()
979 (let ((cl-hold (list cl-tree
)))
980 (cl-nsublis-rec cl-hold
)
983 (defun cl-nsublis-rec (cl-tree) ; uses cl-alist/temp/p/key/test*/if*
984 (while (consp cl-tree
)
985 (let ((cl-temp (cl-check-key (car cl-tree
))) (cl-p cl-alist
))
986 (while (and cl-p
(not (cl-check-test-nokey (car (car cl-p
)) cl-temp
)))
987 (setq cl-p
(cdr cl-p
)))
988 (if cl-p
(setcar cl-tree
(cdr (car cl-p
)))
989 (if (consp (car cl-tree
)) (cl-nsublis-rec (car cl-tree
))))
990 (setq cl-temp
(cl-check-key (cdr cl-tree
)) cl-p cl-alist
)
991 (while (and cl-p
(not (cl-check-test-nokey (car (car cl-p
)) cl-temp
)))
992 (setq cl-p
(cdr cl-p
)))
994 (progn (setcdr cl-tree
(cdr (car cl-p
))) (setq cl-tree nil
))
995 (setq cl-tree
(cdr cl-tree
))))))
998 (defun tree-equal (cl-x cl-y
&rest cl-keys
)
999 "Return t if trees TREE1 and TREE2 have `eql' leaves.
1000 Atoms are compared by `eql'; cons cells are compared recursively.
1001 \nKeywords supported: :test :test-not :key
1002 \n(fn TREE1 TREE2 [KEYWORD VALUE]...)"
1003 (cl-parsing-keywords (:test
:test-not
:key
) ()
1004 (cl-tree-equal-rec cl-x cl-y
)))
1006 (defun cl-tree-equal-rec (cl-x cl-y
)
1007 (while (and (consp cl-x
) (consp cl-y
)
1008 (cl-tree-equal-rec (car cl-x
) (car cl-y
)))
1009 (setq cl-x
(cdr cl-x
) cl-y
(cdr cl-y
)))
1010 (and (not (consp cl-x
)) (not (consp cl-y
)) (cl-check-match cl-x cl-y
)))
1013 (run-hooks 'cl-seq-load-hook
)
1016 ;; byte-compile-dynamic: t
1017 ;; byte-compile-warnings: (not cl-functions)
1018 ;; generated-autoload-file: "cl-loaddefs.el"
1021 ;; arch-tag: ec1cc072-9006-4225-b6ba-d6b07ed1710c
1022 ;;; cl-seq.el ends here