Math 方案中的幻方
我对Scheme还是个新手,尝试通过call/cc和amb操作符来解幻方。目前正在打印:Math 方案中的幻方,math,scheme,callcc,magic-square,Math,Scheme,Callcc,Magic Square,我对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 disti
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))))))
我注意到您的“distinct”过程从不返回假值。您遇到的问题是您的断言总是通过。当您完全删除assert调用时,可以看到这一点,并且结果保持不变。在嵌套的if检查中,应该用布尔值false:#f替换'()