1
(define (removeAll list-a list-b)
(if (empty? list-b)
list-a
(apply
(removeAll((remove (first list-b) list-a) (rest list-b)))
)
)
)
(removeAll '(a b b c c d) '(a c a))
試圖在Dr.Retet中實施remove *操作?
預期成果是在這種情況下
我可以使用刪除'(b b d)
,但我不能使用刪除*本身。目前,我得到這個錯誤: application: not a procedure; expected a procedure that can be applied to arguments given: '(b b c c d) arguments...:
略有不同,在方案或球拍中添加parens *表達式就像在其他語言的表達式之後放置空對*。所以如果(a b)像(b)那樣,那麼((a b))就像是(b)()。這可能是合法的Java表達式......但只有當(b)返回一個沒有參數的函數時。 –
@JohnClements謝謝!如此接近,但我得到''(bbcd)'而不是'(bbd)' – HelloWorld
@hello,我犯了一個錯誤,認爲'remove'會刪除所有出現的元素,而只會刪除第一個出現的元素,所以我改變了我的答案 – Renzo