Reputation: 673
I want to make a if condition like this:
if
((head(c) = 1) or (head(c) = ~1) or (head(c) = ~5) or (head(c) = ~17) or (head(c) = 0))
count +1
else..
the function head return 'a;
It gives me the next error: operator is not a function [tycon dismatch]
operator: bool
in expression
What is the problem? thank you.
Upvotes: 3
Views: 13164
Reputation: 258
It's called orelse
, not just or
and andalso
instead of and
. But orelse
and andalso
are not functions. Citation from Programming in Standard ML '97:
Note in particular that andalso and orelse are not infix functions because they are not strict in their second argument—that is, they do not always force the evaluation of their second argument—and such functions cannot be defined in a strict programming language such as Standard ML. Thus we cannot apply the op keyword to andalso or orelse.
Upvotes: 5
Reputation: 1299
For this example, you could also write:
let val h = head c in
if List.exists (fn x => x = h) [1, ~1, ~5, ~17, 0]
then count + 1
else ...
end
Upvotes: 1