2014-12-06 137 views
0

我无法用let,in定义curried函数。 我有以下代码:未绑定变量或构造函数

filter_many listOfFunc listOfElements = 
let 
    fun allPredicate(element,[]) = true 
     | allPredicate(element,(a,b)::xs) = a(element) andalso (allPredicate(element,xs)) 
    fun isPredicateAux(element) = allPredicate(element,listOfFunc) 
in 
    List.filter isPredicateAux listOfElements 
end; 

的想法是采取的“一个元素列表,并(A,B),而a是一个谓词函数元组的列表。 (fn'a => bool)。 该函数将返回listOfElement中所有返回true的元素给ListOfFunction中的所有谓词。 请将ListOfFunctions中每个元组的第二个变量分开,供以后使用。

试图运行的代码,这peice的我得到以下错误:

stdIn:123.54-123.64 Error: unbound variable or constructor: listOfFunc 
stdIn:125.30-125.44 Error: unbound variable or constructor: listOfElements 
stdIn:1.1-106.11 Error: unbound variable or constructor: filter_many 
stdIn:106.12-106.22 Error: unbound variable or constructor: listOfFunc 
stdIn:106.23-106.37 Error: unbound variable or constructor: listOfElements 

我似乎无法理解是什么导致了这个问题。所有的功能和变量都应该看到那些使用它们的人。我在这里错过了什么?

谢谢。

回答

1

你忘了在你的函数声明前面写fun

+0

那就是尴尬,谢谢 – 2014-12-06 13:48:05