1 ;;; srfi-1.scm --- List Library
3 ;; Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2009, 2010, 2011, 2014 Free Software Foundation, Inc.
5 ;; This library is free software; you can redistribute it and/or
6 ;; modify it under the terms of the GNU Lesser General Public
7 ;; License as published by the Free Software Foundation; either
8 ;; version 3 of the License, or (at your option) any later version.
10 ;; This library is distributed in the hope that it will be useful,
11 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 ;; Lesser General Public License for more details.
15 ;; You should have received a copy of the GNU Lesser General Public
16 ;; License along with this library; if not, write to the Free Software
17 ;; Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 ;;; Some parts from the reference implementation, which is
20 ;;; Copyright (c) 1998, 1999 by Olin Shivers. You may do as you please with
21 ;;; this code as long as you do not remove this copyright notice or
22 ;;; hold me liable for its use.
24 ;;; Author: Martin Grabmueller <mgrabmue@cs.tu-berlin.de>
29 ;; This is an implementation of SRFI-1 (List Library).
31 ;; All procedures defined in SRFI-1, which are not already defined in
32 ;; the Guile core library, are exported. The procedures in this
33 ;; implementation work, but they have not been tuned for speed or
36 ;; This module is fully documented in the Guile Reference Manual.
40 (define-module (srfi srfi-1)
43 ;; cons <= in the core
44 ;; list <= in the core
46 ;; cons* <= in the core
47 ;; make-list <= in the core
57 ;; pair? <= in the core
58 ;; null? <= in the core
66 ;; caar <= in the core
67 ;; cadr <= in the core
68 ;; cdar <= in the core
69 ;; cddr <= in the core
70 ;; caaar <= in the core
71 ;; caadr <= in the core
72 ;; cadar <= in the core
73 ;; caddr <= in the core
74 ;; cdaar <= in the core
75 ;; cdadr <= in the core
76 ;; cddar <= in the core
77 ;; cdddr <= in the core
78 ;; caaaar <= in the core
79 ;; caaadr <= in the core
80 ;; caadar <= in the core
81 ;; caaddr <= in the core
82 ;; cadaar <= in the core
83 ;; cadadr <= in the core
84 ;; caddar <= in the core
85 ;; cadddr <= in the core
86 ;; cdaaar <= in the core
87 ;; cdaadr <= in the core
88 ;; cdadar <= in the core
89 ;; cdaddr <= in the core
90 ;; cddaar <= in the core
91 ;; cddadr <= in the core
92 ;; cdddar <= in the core
93 ;; cddddr <= in the core
94 ;; list-ref <= in the core
115 ;; last-pair <= in the core
117 ;;; Miscelleneous: length, append, concatenate, reverse, zip & count
118 ;; length <= in the core
120 ;; append <= in the core
121 ;; append! <= in the core
124 ;; reverse <= in the core
125 ;; reverse! <= in the core
136 ;;; Fold, unfold & map
146 ;; for-each ; Extended.
150 ;; map-in-order ; Extended.
154 ;;; Filtering & partitioning
155 ;; filter <= in the core
158 ;; filter! <= in the core
174 ;; list-index ; Extended.
175 ;; member ; Extended.
176 ;; memq <= in the core
177 ;; memv <= in the core
180 ;; delete ; Extended.
181 ;; delete! ; Extended.
185 ;;; Association lists
187 ;; assq <= in the core
188 ;; assv <= in the core
194 ;;; Set operations on lists
202 lset-diff+intersection
207 lset-diff+intersection!
209 ;;; Primitive side-effects
210 ;; set-car! <= in the core
211 ;; set-cdr! <= in the core
213 :re-export (cons list cons* make-list pair? null?
214 car cdr caar cadr cdar cddr
215 caaar caadr cadar caddr cdaar cdadr cddar cdddr
216 caaaar caaadr caadar caaddr cadaar cadadr caddar cadddr
217 cdaaar cdaadr cdadar cdaddr cddaar cddadr cdddar cddddr
218 list-ref last-pair length append append! reverse reverse!
219 filter filter! memq memv assq assv set-car! set-cdr!)
220 :replace (iota map for-each map-in-order list-copy list-index member
221 delete delete! assoc)
224 (cond-expand-provide (current-module) '(srfi-1))
226 ;; Load the compiled primitives from the shared library.
228 (load-extension (string-append "libguile-" (effective-version))
235 "Like `cons', but with interchanged arguments. Useful mostly when passed to
236 higher-order procedures."
239 (define (wrong-type-arg caller arg)
240 (scm-error 'wrong-type-arg (symbol->string caller)
241 "Wrong type argument: ~S" (list arg) '()))
243 (define-syntax-rule (check-arg pred arg caller)
245 (wrong-type-arg 'caller arg)))
247 (define (out-of-range proc arg)
248 (scm-error 'out-of-range proc
249 "Value out of range: ~A" (list arg) (list arg)))
251 ;; the srfi spec doesn't seem to forbid inexact integers.
252 (define (non-negative-integer? x) (and (integer? x) (>= x 0)))
254 (define (list-tabulate n init-proc)
255 "Return an N-element list, where each list element is produced by applying the
256 procedure INIT-PROC to the corresponding list index. The order in which
257 INIT-PROC is applied to the indices is not specified."
258 (check-arg non-negative-integer? n list-tabulate)
259 (let lp ((n n) (acc '()))
262 (lp (- n 1) (cons (init-proc (- n 1)) acc)))))
264 (define (circular-list elt1 . elts)
265 (set! elts (cons elt1 elts))
266 (set-cdr! (last-pair elts) elts)
269 (define* (iota count #:optional (start 0) (step 1))
270 (check-arg non-negative-integer? count iota)
271 (let lp ((n 0) (acc '()))
274 (lp (+ n 1) (cons (+ start (* n step)) acc)))))
278 (define (proper-list? x)
281 (define (circular-list? x)
284 (let lp ((hare (cdr x)) (tortoise x))
287 (let ((hare (cdr hare)))
290 (if (eq? hare tortoise)
292 (lp (cdr hare) (cdr tortoise)))))))))
294 (define (dotted-list? x)
299 (let lp ((hare (cdr x)) (tortoise x))
302 ((not-pair? hare) #t)
304 (let ((hare (cdr hare)))
307 ((not-pair? hare) #t)
308 ((eq? hare tortoise) #f)
310 (lp (cdr hare) (cdr tortoise)))))))))))
312 (define (null-list? x)
319 (error "not a proper list in null-list?"))))
321 (define (not-pair? x)
322 "Return #t if X is not a pair, #f otherwise.
324 This is shorthand notation `(not (pair? X))' and is supposed to be used for
325 end-of-list checking in contexts where dotted lists are allowed."
328 (define (list= elt= . rest)
329 (define (lists-equal a b)
330 (let lp ((a a) (b b))
336 (and (elt= (car a) (car b))
337 (lp (cdr a) (cdr b)))))))
339 (check-arg procedure? elt= list=)
341 (let lp ((lists rest))
342 (or (null? (cdr lists))
343 (and (lists-equal (car lists) (cadr lists))
344 (lp (cdr lists)))))))
351 (define fourth cadddr)
352 (define (fifth x) (car (cddddr x)))
353 (define (sixth x) (cadr (cddddr x)))
354 (define (seventh x) (caddr (cddddr x)))
355 (define (eighth x) (cadddr (cddddr x)))
356 (define (ninth x) (car (cddddr (cddddr x))))
357 (define (tenth x) (cadr (cddddr (cddddr x))))
360 "Return two values, the `car' and the `cdr' of PAIR."
361 (values (car x) (cdr x)))
363 (define take list-head)
364 (define drop list-tail)
366 ;;; TAKE-RIGHT and DROP-RIGHT work by getting two pointers into the list,
367 ;;; off by K, then chasing down the list until the lead pointer falls off
368 ;;; the end. Note that they diverge for circular lists.
370 (define (take-right lis k)
371 (let lp ((lag lis) (lead (drop lis k)))
373 (lp (cdr lag) (cdr lead))
376 (define (drop-right lis k)
377 (let recur ((lag lis) (lead (drop lis k)))
379 (cons (car lag) (recur (cdr lag) (cdr lead)))
382 (define (take! lst i)
383 "Linear-update variant of `take'."
386 (let ((tail (drop lst (- i 1))))
390 (define (drop-right! lst i)
391 "Linear-update variant of `drop-right'."
392 (let ((tail (drop lst i)))
395 (let loop ((prev lst)
406 (define (split-at lst i)
407 "Return two values, a list of the elements before index I in LST, and
408 a list of those after."
410 (out-of-range 'split-at i)
411 (let lp ((l lst) (n i) (acc '()))
413 (values (reverse! acc) l)
414 (lp (cdr l) (- n 1) (cons (car l) acc))))))
416 (define (split-at! lst i)
417 "Linear-update variant of `split-at'."
419 (out-of-range 'split-at! i))
423 (let lp ((l lst) (n (- i 1)))
428 (lp (cdr l) (- n 1)))))))
431 "Return the last element of the non-empty, finite list PAIR."
432 (car (last-pair pair)))
434 ;;; Miscelleneous: length, append, concatenate, reverse, zip & count
436 (define (zip clist1 . rest)
437 (let lp ((l (cons clist1 rest)) (acc '()))
440 (lp (map cdr l) (cons (map car l) acc)))))
446 (values (map first l) (map second l)))
448 (values (map first l) (map second l) (map third l)))
450 (values (map first l) (map second l) (map third l) (map fourth l)))
452 (values (map first l) (map second l) (map third l) (map fourth l)
455 ;;; Fold, unfold & map
459 "Apply PROC to the elements of LIST1 ... LISTN to build a result, and return
460 that result. See the manual for details."
462 (check-arg procedure? kons fold)
463 (check-arg list? list1 fold)
464 (let fold1 ((knil knil) (list1 list1))
466 (fold1 (kons (car list1) knil) (cdr list1))
468 ((kons knil list1 list2)
469 (check-arg procedure? kons fold)
470 (let* ((len1 (length+ list1))
471 (len2 (length+ list2))
472 (len (if (and len1 len2)
476 (scm-error 'wrong-type-arg "fold"
477 "Args do not contain a proper (finite) list: ~S"
478 (list (list list1 list2)) #f))
479 (let fold2 ((knil knil) (list1 list1) (list2 list2) (len len))
482 (fold2 (kons (car list1) (car list2) knil)
483 (cdr list1) (cdr list2) (1- len))))))
484 ((kons knil list1 . rest)
485 (check-arg procedure? kons fold)
486 (let foldn ((knil knil) (lists (cons list1 rest)))
487 (if (any null? lists)
489 (let ((cars (map car lists))
490 (cdrs (map cdr lists)))
491 (foldn (apply kons (append! cars (list knil))) cdrs)))))))
493 (define (fold-right kons knil clist1 . rest)
494 (check-arg procedure? kons fold-right)
496 (let loop ((lst (reverse clist1))
501 (kons (car lst) result))))
502 (let loop ((lists (map reverse (cons clist1 rest)))
504 (if (any1 null? lists)
506 (loop (map cdr lists)
507 (apply kons (append! (map car lists) (list result))))))))
509 (define (pair-fold kons knil clist1 . rest)
510 (check-arg procedure? kons pair-fold)
512 (let f ((knil knil) (list1 clist1))
515 (let ((tail (cdr list1)))
516 (f (kons list1 knil) tail))))
517 (let f ((knil knil) (lists (cons clist1 rest)))
518 (if (any null? lists)
520 (let ((tails (map cdr lists)))
521 (f (apply kons (append! lists (list knil))) tails))))))
524 (define (pair-fold-right kons knil clist1 . rest)
525 (check-arg procedure? kons pair-fold-right)
527 (let f ((list1 clist1))
530 (kons list1 (f (cdr list1)))))
531 (let f ((lists (cons clist1 rest)))
532 (if (any null? lists)
534 (apply kons (append! lists (list (f (map cdr lists)))))))))
536 (define* (unfold p f g seed #:optional (tail-gen (lambda (x) '())))
537 (define (reverse+tail lst seed)
539 (result (tail-gen seed)))
543 (cons (car lst) result)))))
545 (check-arg procedure? p unfold)
546 (check-arg procedure? f unfold)
547 (check-arg procedure? g unfold)
548 (check-arg procedure? tail-gen unfold)
549 (let loop ((seed seed)
552 (reverse+tail result seed)
554 (cons (f seed) result)))))
556 (define* (unfold-right p f g seed #:optional (tail '()))
557 (check-arg procedure? p unfold-right)
558 (check-arg procedure? f unfold-right)
559 (check-arg procedure? g unfold-right)
560 (let uf ((seed seed) (lis tail))
563 (uf (g seed) (cons (f seed) lis)))))
565 (define (reduce f ridentity lst)
566 "`reduce' is a variant of `fold', where the first call to F is on two
567 elements from LST, rather than one element and a given initial value.
568 If LST is empty, RIDENTITY is returned. If LST has just one element
569 then that's the return value."
570 (check-arg procedure? f reduce)
573 (fold f (car lst) (cdr lst))))
575 (define (reduce-right f ridentity lst)
576 "`reduce-right' is a variant of `fold-right', where the first call to
577 F is on two elements from LST, rather than one element and a given
578 initial value. If LST is empty, RIDENTITY is returned. If LST
579 has just one element then that's the return value."
580 (check-arg procedure? f reduce)
583 (fold-right f (last lst) (drop-right lst 1))))
588 (check-arg procedure? f map)
589 (check-arg list? l map)
592 (cons (f (car l)) (map1 (cdr l)))
596 (check-arg procedure? f map)
597 (let* ((len1 (length+ l1))
599 (len (if (and len1 len2)
603 (scm-error 'wrong-type-arg "map"
604 "Args do not contain a proper (finite) list: ~S"
605 (list (list l1 l2)) #f))
606 (let map2 ((l1 l1) (l2 l2) (len len))
609 (cons (f (car l1) (car l2))
610 (map2 (cdr l1) (cdr l2) (1- len)))))))
613 (check-arg procedure? f map)
614 (let ((len (fold (lambda (ls len)
615 (let ((ls-len (length+ ls)))
617 (if ls-len (min ls-len len) len)
622 (scm-error 'wrong-type-arg "map"
623 "Args do not contain a proper (finite) list: ~S"
624 (list (cons l1 rest)) #f))
625 (let mapn ((l1 l1) (rest rest) (len len))
628 (cons (apply f (car l1) (map car rest))
629 (mapn (cdr l1) (map cdr rest) (1- len)))))))))
631 (define map-in-order map)
636 (check-arg procedure? f for-each)
637 (check-arg list? l for-each)
638 (let for-each1 ((l l))
641 (for-each1 (cdr l)))))
644 (check-arg procedure? f for-each)
645 (let* ((len1 (length+ l1))
647 (len (if (and len1 len2)
651 (scm-error 'wrong-type-arg "for-each"
652 "Args do not contain a proper (finite) list: ~S"
653 (list (list l1 l2)) #f))
654 (let for-each2 ((l1 l1) (l2 l2) (len len))
656 (f (car l1) (car l2))
657 (for-each2 (cdr l1) (cdr l2) (1- len))))))
660 (check-arg procedure? f for-each)
661 (let ((len (fold (lambda (ls len)
662 (let ((ls-len (length+ ls)))
664 (if ls-len (min ls-len len) len)
669 (scm-error 'wrong-type-arg "for-each"
670 "Args do not contain a proper (finite) list: ~S"
671 (list (cons l1 rest)) #f))
672 (let for-eachn ((l1 l1) (rest rest) (len len))
675 (apply f (car l1) (map car rest))
676 (for-eachn (cdr l1) (map cdr rest) (1- len)))))))))
678 (define (append-map f clist1 . rest)
679 (concatenate (apply map f clist1 rest)))
681 (define (append-map! f clist1 . rest)
682 (concatenate! (apply map f clist1 rest)))
684 ;; OPTIMIZE-ME: Re-use cons cells of list1
687 (define (filter-map proc list1 . rest)
688 "Apply PROC to the elements of LIST1... and return a list of the
689 results as per SRFI-1 `map', except that any #f results are omitted from
691 (check-arg procedure? proc filter-map)
697 (let ((res (proc (car l))))
699 (lp (cdr l) (cons res rl))
701 (let lp ((l (cons list1 rest))
705 (let ((res (apply proc (map car l))))
707 (lp (map cdr l) (cons res rl))
708 (lp (map cdr l) rl)))))))
710 (define (pair-for-each f clist1 . rest)
711 (check-arg procedure? f pair-for-each)
719 (let lp ((l (cons clist1 rest)))
724 (lp (map cdr l)))))))
729 (define (take-while pred ls)
730 "Return a new list which is the longest initial prefix of LS whose
731 elements all satisfy the predicate PRED."
732 (check-arg procedure? pred take-while)
733 (cond ((null? ls) '())
734 ((not (pred (car ls))) '())
736 (let ((result (list (car ls))))
737 (let lp ((ls (cdr ls)) (p result))
738 (cond ((null? ls) result)
739 ((not (pred (car ls))) result)
741 (set-cdr! p (list (car ls)))
742 (lp (cdr ls) (cdr p)))))))))
744 (define (take-while! pred lst)
745 "Linear-update variant of `take-while'."
746 (check-arg procedure? pred take-while!)
752 (loop rest (cdr rest)))
760 (define (drop-while pred lst)
761 "Drop the longest initial prefix of LST whose elements all satisfy the
763 (check-arg procedure? pred drop-while)
764 (let loop ((lst lst))
771 (define (span pred lst)
772 "Return two values, the longest initial prefix of LST whose elements
773 all satisfy the predicate PRED, and the remainder of LST."
774 (check-arg procedure? pred span)
775 (let lp ((lst lst) (rl '()))
776 (if (and (not (null? lst))
778 (lp (cdr lst) (cons (car lst) rl))
779 (values (reverse! rl) lst))))
781 (define (span! pred list)
782 "Linear-update variant of `span'."
783 (check-arg procedure? pred span!)
789 (loop rest (cdr rest)))
795 (values '() list))))))
797 (define (break pred clist)
798 "Return two values, the longest initial prefix of LST whose elements
799 all fail the predicate PRED, and the remainder of LST."
800 (check-arg procedure? pred break)
801 (let lp ((clist clist) (rl '()))
802 (if (or (null? clist)
804 (values (reverse! rl) clist)
805 (lp (cdr clist) (cons (car clist) rl)))))
807 (define (break! pred list)
808 "Linear-update variant of `break'."
809 (check-arg procedure? pred break!)
823 (define (any pred ls . lists)
824 (check-arg procedure? pred any)
827 (let lp ((lists (cons ls lists)))
828 (cond ((any1 null? lists)
830 ((any1 null? (map cdr lists))
831 (apply pred (map car lists)))
833 (or (apply pred (map car lists)) (lp (map cdr lists))))))))
835 (define (any1 pred ls)
842 (or (pred (car ls)) (lp (cdr ls)))))))
844 (define (every pred ls . lists)
845 (check-arg procedure? pred every)
848 (let lp ((lists (cons ls lists)))
849 (cond ((any1 null? lists)
851 ((any1 null? (map cdr lists))
852 (apply pred (map car lists)))
854 (and (apply pred (map car lists)) (lp (map cdr lists))))))))
856 (define (every1 pred ls)
863 (and (pred (car ls)) (lp (cdr ls)))))))
865 (define (list-index pred clist1 . rest)
866 "Return the index of the first set of elements, one from each of
867 CLIST1 ... CLISTN, that satisfies PRED."
868 (check-arg procedure? pred list-index)
870 (let lp ((l clist1) (i 0))
875 (lp (cdr l) (+ i 1)))))
876 (let lp ((lists (cons clist1 rest)) (i 0))
877 (cond ((any1 null? lists)
879 ((apply pred (map car lists)) i)
881 (lp (map cdr lists) (+ i 1)))))))
883 ;;; Association lists
885 (define alist-cons acons)
887 (define (alist-copy alist)
888 "Return a copy of ALIST, copying both the pairs comprising the list
889 and those making the associations."
894 (lp (cdr a) (alist-cons (caar a) (cdar a) rl)))))
896 (define* (alist-delete key alist #:optional (k= equal?))
897 (check-arg procedure? k= alist-delete)
898 (let lp ((a alist) (rl '()))
901 (if (k= key (caar a))
903 (lp (cdr a) (cons (car a) rl))))))
905 (define* (alist-delete! key alist #:optional (k= equal?))
906 (alist-delete key alist k=)) ; XXX:optimize
908 ;;; Delete / assoc / member
910 (define* (member x ls #:optional (= equal?))
912 ;; This might be performance-sensitive, so punt on the check here,
913 ;; relying on memq/memv to check that = is a procedure.
914 ((eq? = eq?) (memq x ls))
915 ((eq? = eqv?) (memv x ls))
917 (check-arg procedure? = member)
918 (find-tail (lambda (y) (= x y)) ls))))
920 ;;; Set operations on lists
922 (define (lset<= = . rest)
923 (check-arg procedure? = lset<=)
926 (let lp ((f (car rest)) (r (cdr rest)))
928 (and (every (lambda (el) (member el (car r) =)) f)
929 (lp (car r) (cdr r)))))))
931 (define (lset= = . rest)
932 (check-arg procedure? = lset<=)
935 (let lp ((f (car rest)) (r (cdr rest)))
937 (and (every (lambda (el) (member el (car r) =)) f)
938 (every (lambda (el) (member el f (lambda (x y) (= y x)))) (car r))
939 (lp (car r) (cdr r)))))))
941 ;; It's not quite clear if duplicates among the `rest' elements are meant to
942 ;; be cast out. The spec says `=' is called as (= lstelem restelem),
943 ;; suggesting perhaps not, but the reference implementation shows the "list"
944 ;; at each stage as including those elements already added. The latter
945 ;; corresponds to what's described for lset-union, so that's what's done.
947 (define (lset-adjoin = list . rest)
948 "Add to LIST any of the elements of REST not already in the list.
949 These elements are `cons'ed onto the start of LIST (so the return shares
950 a common tail with LIST), but the order they're added is unspecified.
952 The given `=' procedure is used for comparing elements, called
953 as `(@var{=} listelem elem)', i.e., the second argument is one of the
954 given REST parameters."
955 ;; If `=' is `eq?' or `eqv?', users won't be able to tell which arg is
956 ;; first, so we can pass the raw procedure through to `member',
957 ;; allowing `memq' / `memv' to be selected.
959 (if (or (eq? = eq?) (eq? = eqv?))
962 (check-arg procedure? = lset-adjoin)
963 (lambda (x y) (= y x)))))
965 (let lp ((ans list) (rest rest))
968 (lp (if (member (car rest) ans pred)
970 (cons (car rest) ans))
973 (define (lset-union = . rest)
974 ;; Likewise, allow memq / memv to be used if possible.
976 (if (or (eq? = eq?) (eq? = eqv?))
979 (check-arg procedure? = lset-union)
980 (lambda (x y) (= y x)))))
982 (fold (lambda (lis ans) ; Compute ANS + LIS.
983 (cond ((null? lis) ans) ; Don't copy any lists
984 ((null? ans) lis) ; if we don't have to.
987 (fold (lambda (elt ans)
988 (if (member elt ans pred)
995 (define (lset-intersection = list1 . rest)
996 (check-arg procedure? = lset-intersection)
997 (let lp ((l list1) (acc '()))
1000 (if (every (lambda (ll) (member (car l) ll =)) rest)
1001 (lp (cdr l) (cons (car l) acc))
1002 (lp (cdr l) acc)))))
1004 (define (lset-difference = list1 . rest)
1005 (check-arg procedure? = lset-difference)
1008 (let lp ((l list1) (acc '()))
1011 (if (any (lambda (ll) (member (car l) ll =)) rest)
1013 (lp (cdr l) (cons (car l) acc)))))))
1015 ;(define (fold kons knil list1 . rest)
1017 (define (lset-xor = . rest)
1018 (check-arg procedure? = lset-xor)
1019 (fold (lambda (lst res)
1020 (let lp ((l lst) (acc '()))
1022 (let lp0 ((r res) (acc acc))
1025 (if (member (car r) lst =)
1027 (lp0 (cdr r) (cons (car r) acc)))))
1028 (if (member (car l) res =)
1030 (lp (cdr l) (cons (car l) acc))))))
1034 (define (lset-diff+intersection = list1 . rest)
1035 (check-arg procedure? = lset-diff+intersection)
1036 (let lp ((l list1) (accd '()) (acci '()))
1038 (values (reverse! accd) (reverse! acci))
1039 (let ((appears (every (lambda (ll) (member (car l) ll =)) rest)))
1041 (lp (cdr l) accd (cons (car l) acci))
1042 (lp (cdr l) (cons (car l) accd) acci))))))
1045 (define (lset-union! = . rest)
1046 (check-arg procedure? = lset-union!)
1047 (apply lset-union = rest)) ; XXX:optimize
1049 (define (lset-intersection! = list1 . rest)
1050 (check-arg procedure? = lset-intersection!)
1051 (apply lset-intersection = list1 rest)) ; XXX:optimize
1053 (define (lset-xor! = . rest)
1054 (check-arg procedure? = lset-xor!)
1055 (apply lset-xor = rest)) ; XXX:optimize
1057 (define (lset-diff+intersection! = list1 . rest)
1058 (check-arg procedure? = lset-diff+intersection!)
1059 (apply lset-diff+intersection = list1 rest)) ; XXX:optimize
1061 ;;; srfi-1.scm ends here