2013-03-06 58 views
0

我還是新來的計劃,並試圖通過呼叫/ cc和amb運算符來解決幻方。目前,它正在打印:幻方正在計劃中

1 1 1 31 Row 1 
16 16 1 1 Row 2 
16 1 16 1 Row 3 
1 16 16 1 Row 4 

我不明白爲什麼它只使用這些數字。這是我的獨特之處嗎?程序?這裏是我的代碼:

;; check whether an element of one given list is a member of any 
;; of the other given lists 
(define distinct? 
    (lambda (o l) 
    (if (null? l) 
    #t 
    (if (= (car l) o) 
      '() 
      (distinct? o (cdr l)))))) 

回答

0

我注意到你的'獨特?'過程永遠不會返回錯誤的值。你運行的問題是你的斷言總是通過。這可以在您完全刪除斷言調用時看到,並且結果不變。在你嵌套的if檢查中,你應該用布爾值false替換你的'():#f