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.
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_seqreturns anint, which means yourConsis trying to cons anintonto anint. That makes no sense, because cons is for adding an element to the front of a list (yourConsfunction is expecting to put aninton 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_seqis wrong, because iffind_CLC_seqis really meant to return anint, it doesn’t make sense to be using it that way;OR your definition of
find_CLC_seqis wrong, and its return type should beint seqor a lazy sequence, as the name implies. In that case, the error is in a bit of code you haven’t shown us.