Programing Gauche p53のcopy-listという手続き
(define (copy-list lis)
(if (pair? lis)
(cons (car lis) (copy-list (cdr lis)))
lis))
(copy-list '(aa bb cc))
(cons (car '(aa bb cc)) (copy-list (cdr '(aa bb cc))))
(cons 'aa (copy-list (cdr '(aa bb cc))))
(cons 'aa (copy-list '(bb cc)))
(cons 'aa (cons (car '(bb cc)) (copy-list (cdr '(bb cc)))))
(cons 'aa (cons 'bb (copy-list '(cc))))
(cons 'aa (cons 'bb (cons (car'(cc)) (copy-list (cdr '(cc))))))
(cons 'aa (cons 'bb (cons 'cc (copy-list ()))))
(cons 'aa (cons 'bb (cons 'cc ())))
(cons 'aa (cons'bb'(cc)))
(cons 'aa'(bb cc))
'(aa bb cc)
Programing Gauche p54のappend2という手続き
(define (append2 a b)
(if (pair? a)
(cons (car a) (append2 (cdr a) b))
b))
(append2 '(aa bb) '(cc))
(cons (car '(aa bb)) (append2 (cdr '(aa bb)) '(cc)))
(cons 'aa (append2 '(bb) '(cc)))
(cons 'aa (append2 '(bb) '(cc)))
(cons 'aa (cons (car '(bb)) (append2 (cdr '(bb)) '(cc))))
(cons 'aa (cons 'bb (append2 () '(cc))))
(cons 'aa (cons 'bb (append2 () '(cc))))
(cons 'aa (cons 'bb '(cc)))
(cons 'aa '(bb cc))
'(aa bb cc)