Prolog member function -


i trying return true if object in obj false otherwise. built in member function not give me true or false. gives me obj shown. how make return true or false ?

member(communicator,obj). obj = [communicator|_g3422]. 

from comments sounds you're not following how prolog works @ prompt.

if enter this:

?- obj = [communicator, gun]. obj = [communicator, gun]. 

and ends in period, prolog satisfy query instantiating obj [communicator, gun] , show final solution: obj = [communicator, gun]..

at point, expression done, , obj no longer has value after solution found. subsequent call member/2 shows this:

?- member(communicator, obj). obj = [communicator|_g51] ; 

what need instantiate obj in same logical clause:

?- obj = [communicator, gun], member(communicator, obj). obj = [communicator, gun] ; false.  ?- 

note comma, , in prolog. prolog succeeded , found 1 solution (obj = [communicator, gun] , then, after enter ; find more solutions, finds no more , displays, false.


Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -