这是我第一次尝试在Scheme&我好像被困在了最后。该程序将获取一个数字,两个子集和拉数等于相同总和的列表。即; 5 + 2 = 7和4 + 3 = 7.程序应打印两个子集{5 2} {4 3} 我收到错误"否则:不允许作为表达式"而我似乎无法理解为什么。任何提示或方向都表示赞赏。
(define two-subsets (lambda (list count sum1 sum2)
(cond ((and (not (= count 0) (= sum1) (= sum2) #t)
((null? list) #f)
((two-subsets (cdr list) (+ count) (+ sum1) (+ sum2 (car list) #t)
((two-subsets (cdr list) (+ count 1) (- sum1) (- sum2 (car list) #t)
(else (two-subsets (cdr list) count sum1 sum2)))
))))