;; This came from RScheme; it has been modified for Guile. ;; See: list.c, scm_append_x, HOBBITIZED_APPEND_X ;;;guile> (chdir "/usr/local/src/Lisp_Scheme/Guile/guile-libs") ;;;guile> (use-modules (ice-9 slib)) ;;;guile> (load "ghobbit.scm") ;;;guile> (hobbit "append!.scm") ;;;Starting to read append!.scm ;;;Bounded integer (fast) arithmetic assumed. ;;;** Pass 1 completed ** ;;;** Pass 2 completed ** ;;;** Pass 3 completed ** ;;;** Pass 4 completed ** ;;;** Pass 5 completed ** ;;;** Pass 6 completed ** ;;;C source file append!.c is built. ;;;C header file append!.h is built. ;;;guile> (define (append! . args) (and (null? args) (set! args '(()))) ;; (assert-ta (all-but-last (lambda (elt) ;; (or (null? elt) ;; (list? elt))) ;; args)) (let ((target (car args)) (tails (cdr args))) (let tloop ((target target) (tails tails)) (if (null? target) (if (pair? tails) (tloop (car tails) (cdr tails)) '()) (let loop ((tails tails) (p target)) (if (null? tails) target (let ((new-tail (car tails))) (if (null? new-tail) (loop (cdr tails) p) (begin (set-cdr! (last-pair p) new-tail) (loop (cdr tails) new-tail))))))))))