Reputation: 61
I have a list of items, which is in a method. I'm using another method to call out the list but I do not want to input the list inside that method. How can I solve this?
foo([a,b,c,d,e]).
hi:- read(X),member(X,[a,b,c,d,e]).
?- hi.
|: a.
true.
I want to change the list in the go(X), using the foo(X) but it does not work. I know that foo(X) returns [a,b,c,d,e].
foo([a,b,c,d,e]).
hi:- read(X),member(X,foo(X)).
k
Upvotes: 0
Views: 354
Reputation: 23705
first associate list with variable then use it in member()
:
hi:- read(X),foo(Y), member(X,Y).
in Prolog rules do not return value. they checks(if variable has already associated with value or constant is passed) or associate(if variable passed has not been associated yet)
Upvotes: 2