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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -