(make-arity-dispatched-procedure
(named-lambda (append self . lists)
self
- (let recur ((lists lists))
- (if (pair? lists) ; Recursion limited by number of args.
- (%append-2 (car lists) (recur (cdr lists)))
- '())))
+ (if (pair? lists)
+ (let recur ((lists lists))
+ ;; Recursion limited by number of arguments.
+ (let ((list0 (car lists))
+ (lists (cdr lists)))
+ (if (pair? lists)
+ (%append-2 list0 (recur lists))
+ list0)))
+ '()))
(lambda () '())
(lambda (l) l)
%append-2))
-
+\f
(define (%append-2! l1 l2)
(if (pair? l1)
(begin (set-cdr! (last-pair l1) l2)
(make-arity-dispatched-procedure
(named-lambda (append! self . lists)
self
- (let recur ((lists lists))
- (if (pair? lists) ; Recursion limited by number of args.
- (%append-2! (car lists) (recur (cdr lists)))
- '())))
+ (if (pair? lists)
+ (let recur ((lists lists))
+ ;; Recursion limited by number of arguments.
+ (let ((list0 (car lists))
+ (lists (cdr lists)))
+ (if (pair? lists)
+ (%append-2! list0 (recur lists))
+ list0)))
+ '()))
(lambda () '())
(lambda (l) l)
%append-2!))
(lambda ()
(assert-equal (append 'x) 'x)
(assert-equal (append '(x) 'y) '(x . y))
- (expect-error
- (lambda ()
- (assert-equal (append '(x) '(y) 'z) '(x y . z))))))
+ (assert-equal (append '(x) '(y) 'z) '(x y . z))))
(define-test 'append!-dotted
(lambda ()
(assert-equal (append! 'x) 'x)
(assert-equal (append! (list 'x) 'y) '(x . y))
- (expect-error
- (lambda ()
- (assert-equal (append! (list 'x) (list 'y) 'z) '(x y . z))))))
+ (assert-equal (append! (list 'x) (list 'y) 'z) '(x y . z))))
(define-test 'map-long
(lambda ()