; ======================================================================
;
; Structure and Interpretation of Computer Programs
; (trial answer to excercises)
;
; 计算机程序的构造和解释(习题试解)
;
; created: code17 07/28/05
; modified:
; (保持内容完整不变前提下,可以任意转载)
; ======================================================================
;; SICP No.2.28
(define (finger x)
(cond ((pair? x) (append (finger (car x)) (finger (cdr x))))
((null? x) x)
(else (list x))))
;; Test-it:
;; Welcome to MzScheme version 209, Copyright (c) 2004 PLT Scheme, Inc.
;; > (define x (list (list 1 2) (list 3 4)))
;; > x
;; ((1 2) (3 4))
;; > (finger x)
;; (1 2 3 4)