Ryan Miles
Ryan Miles

Reputation: 309

Operator and operand don't agree ML

I'm working on a function for class, and I am getting this error.

Error: operator and operand don't agree [tycon mismatch]

operator domain: 'Z list

operand: 'Y list -> 'Y list

in expression: null tl

fun removedub(L) =
  if (null L) then nil
  else if (null tl(L)) then hd(L)
  else if hd(L) = hd(tl(L)) then removedub(tl(L))
  else hd(L) :: removedub(tl(L));



val list = ["a", "a", "b", "b", "c"];

removedub(list);

I'm not sure how to fix this, or really what is causing it, any tips?

Upvotes: 0

Views: 287

Answers (1)

Andreas Rossberg
Andreas Rossberg

Reputation: 36118

You set the parentheses wrong. When you write

null tl(L)

then that has the same meaning as

null(tl)(L)

However, you want

null(tl(L))

Upvotes: 0

Related Questions