Posted on 2008-11-04 01:20
dennis 閱讀(1631)
評論(0) 編輯 收藏 所屬分類:
計算機(jī)科學(xué)與基礎(chǔ)
本節(jié)開始介紹神奇的amb函數(shù),為引入邏輯程序設(shè)計做鋪墊。關(guān)于amb,有清華王垠的一個文檔:
http://cs2.swfc.edu.cn/~wanghuan/wangyin1/amb/amb.html
4.35,與an-element-of類似:
(define (an-integer-between low high)
(require (not (> low high)))
(amb low (an-integer-between (+ low 1) high)))
4.36,與練習(xí)3.69相關(guān),貌似我沒解過這道題,略過。
4.37,兩點(diǎn)大大縮小了搜索范圍:
1)通過限制i^2+j^2<= high^2,平方和大于上限平方的全部過濾掉
2)k的判斷不再通過amb取值,而是求平方和的平方根是否為整數(shù)來判斷,進(jìn)一步縮小了搜索范圍