2014-05-11 72 views
0

在方案中,我想實現一個將謂詞作爲參數的函數。(scheme)謂詞作爲函數的參數

(define (delete-rows table predicate) 
(filter predicate (cddr table) 
) 
) 

這是我的功能,其過濾取決於謂詞 名單,我想調用函數如下

(delete-rows student-table 
(lambda (table row) ;this is the predicate (two lines) 
(eq? (get table row 'name) 'mehmet))) 

但它給像

filter: contract violation 
expected: (any/c . -> . any/c) 
given: #<procedure:...cuments\mumu.rkt:88:0> 
+0

請參閱http://stackoverflow.com/q/23595759/1193075 – uselpa

+0

他問我幾分鐘前 – arslanbenzer

回答

0

你的斷言需要2個錯誤參數(表格,行),但filter將僅使用一個參數(要處理的元素)調用謂詞。因此錯誤。

查看我對this question解答的回答。