Assigning a variable rather than checking for truth value with ->

163 Views Asked by At

I am attempting to assign a variable with an empty list like this:

stuff(_) :- (not(is_list(X)) -> X is []), ...

or

stuff(_) :- (not(is_list(X)) -> X = []), ...

What I want is for X to meet the condition that X is not a list in order to assign X with an empty list. It can't be like:

 not(is_list(X)), X = [] 

Because "X is not list" condition must be met. But when I try the above code, all it does is try to check the truth value of X = [] or X is [] instead of assigning X with the empty list.

I don't necessary have to use ->. It can be anything. As long as X is assigned [] if X is not already a list. As the consequent of stuff(_) relation.

0

There are 0 best solutions below