0
votes

I have this simple function:

val CLC_seq=
       fn (n) =>
       (Cons (n, find_CLC_seq(COL_seq(n))))

When:

find_CLC_sqe is : int seq -> int;
COL_seq is: fn: int -> int seq;

The complier wrote:

Error: operator and operand don't agree
operator domain: int * (Unit -> int seq)
operand: int * int
in expression: 
 (Cons (n, find_CLC_seq(COL_seq(n))))

What is the reason? How can I solve it? Thank you.

1

1 Answers

0
votes

Well, it's not clear what you're trying to do exactly, but the compiler is right to pick you up on it. find_CLC_seq returns an int, which means your Cons is trying to cons an int onto an int. That makes no sense, because cons is for adding an element to the front of a list (your Cons function is expecting to put an int on the front of a lazy sequence, a (Unit -> int seq)).

I don't know what CLC and COL are, but it looks like either:

Your definition of CLC_seq is wrong, because if find_CLC_seq is really meant to return an int, it doesn't make sense to be using it that way;

OR your definition of find_CLC_seq is wrong, and its return type should be int seq or a lazy sequence, as the name implies. In that case, the error is in a bit of code you haven't shown us.