Mark Vaykhansky
Mark Vaykhansky

Reputation: 7

Unbound variable or constructor

I'm having trouble defineing a curried function with let,in,end. I have the following code:

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;

The idea is to take a list of 'a element and a list of tuples (a,b) while a is a predicate function. (fn 'a=> bool). The function will return all of the elements in the listOfElement that return true to all the predicates in ListOfFunction. please disreagrd the second variables of each tuple in ListOfFunctions, it's for later usage.

While trying to run this peice of code I get the following error:

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

I can't seem to understand what's causing this problem. All of the functions and variables should be seen to those using them. What am I missing here?

Thanks.

Upvotes: 0

Views: 1777

Answers (1)

You forgot to write fun in front of your function declaration.

Upvotes: 1

Related Questions