list - How to print all the facts? -


i stuck problem...

isat(keys, room3). isat(book, room3). isat(keys, room6). isat(keys, room4). 

currently, room3 have keys , book. want print keys , book. tried code , apparently prints one. (just keys)

look :- isin(location),   write('you in '),   write(location),   nl,   items_inroom(location),   nl.   items_inroom(location) :-     isin(location),     isat(item, location),     write('available item(s):'),      write(item),     nl.  items_inroom(_) :-     write('available item(s): none'),     nl.  

items_inroom code trying print these facts. how can approach this? great! thank you.

find items , display them.

items_inroom(location) :-     write('available item(s):'),     findall(item, isat(item, location), items),     show_items(items).  show_items([]) :-     write('none'), !.  show_items(items) :-      write(items). 

actually can implement show_items(items) in way want.


Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

Kivy: Swiping (Carousel & ScreenManager) -