Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
26 lines (20 sloc) 545 Bytes
(load "../lib/square")
;;; 高階手続きを使わずに定義
(define (square-tree tree)
(cond ((null? tree) '())
((pair? tree)
(cons (square-tree (car tree))
(square-tree (cdr tree))))
(else (square tree))))
;;; map と再帰を使って定義
(define (square-tree tree)
(map (lambda (sub-tree)
(if (pair? sub-tree)
(square-tree sub-tree)
(square sub-tree)))
;;; 使用例
(list 1
(list 2 (list 3 4) 5)
(list 6 7)))
You can’t perform that action at this time.