re:schemeで全dataを+するのを知りたいです
こんな感じかな?
http://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1347295398
http://d.hatena.ne.jp/yad-EL/20100921/p1
(define (mysum xs) (fold (lambda (x acc) (+ (if (list? x) (mysum x) x) acc)) 0 xs)) ;; (mysum 20) ;; (mysum '()) ; => 0 ;; (mysum '(1 2 3)) ; => 6 ;; (mysum '((1 2) ((3)) (4 (5)))) ; => 15 (define (tree-map fn tree) (map (lambda (x) (if (list? x) (tree-map fn x) (fn x))) tree)) (define (mytrans xs) (let1 source '(zero one two three four five six seven eight nine) (cond ((null? xs) 0) (else (tree-map (pa$ list-ref source) xs))))) ;; (mytrans 1) ;; (mytrans '()) ;; (mytrans '(1 2 3)) ; => (one two three) ;; (mytrans '((1 2) ((3)) (4 (5 6)))) ; => ((one two) ((three)) (four (five six))) (define (my-find xs e) (and-let* ((pair (assoc e xs))) (cadr pair))) ;; (my-find 10) ;; (my-find 'a) ;; (my-find '((x 10) (y 20) (x 30)) 'x) ; => 10 ;; (my-find '((x 10) (y 20) (x 30)) 'i) ; => #f