0

我仍然是 Scheme 的新手,并试图通过 call/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))))))
4

1 回答 1

0

我注意到你的“与众不同?” 过程从不返回错误值。您遇到的问题是您的断言总是通过。当您完全删除 assert 的调用时可以看到这一点,结果没有改变。在您的嵌套 if 检查中,您应该将您的 '() 替换为布尔值 false:#f

于 2013-03-07T02:35:53.937 回答