이 문제는 앞에서 보았던 right-split와 up-split 프로시저보다 활용도가 높은

split 프로시저를 만드는 문제입니다.

 

c10

split 프로시저를 만들고 각각에 적용시켜보니 잘 작동되는군요.^^

 

 

참조

해럴드 애빌슨, 김재우 역, <컴퓨터 프로그램의 구조와 해석>, 인사이트, 2007, pp. 173

 

 

; library
(require "paint/painters.ss")

; answer
(define (split small-combine combine)
  (lambda (painter n)
    (if (= n 0)
      painter
      (let ((smaller ((split small-combine combine) painter (- n 1))))
        (combine painter (small-combine smaller smaller))))))

; new definition
(define right-split (split beside below))
(define up-split (split below beside))

; execute
(define Sungnyemun
  (load-painter
   (build-path "Sungnyemun.jpg")))

(paint Sungnyemun)
(paint (up-split Sungnyemun 3))
(paint (right-split Sungnyemun 3))

크리에이티브 커먼즈 라이선스
Creative Commons License

글에 잘못된 점, 다른 점, 부족한 점이 있다면 지적해주세요.
댓글, 트랙백, 메일 모두 고맙습니다.

트랙백 주소 :: http://nosyu.pe.kr/trackback/1358

댓글을 달아 주세요

[로그인][오픈아이디란?]