I was trying to make a function that if one is negative, return the other.
foo(X,Y,F):- **X**<=0,F is Y.
foo(X,Y,F):- **Y**<=0,F is X.
is showing error... how to fix this?(** is the highlighted part)
I was trying to make a function that if one is negative, return the other.
foo(X,Y,F):- **X**<=0,F is Y.
foo(X,Y,F):- **Y**<=0,F is X.
is showing error... how to fix this?(** is the highlighted part)
As the comment says;
=<not<=:But a few more thoughts.
Rather than
is, we can simply use identity:Which has the advantage of working in more cases where not all variables are instantiated. Finally, it can also be written through pattern matching: