Basic Question

25 views
Skip to first unread message

i.quot...@gmail.com

unread,
Feb 17, 2018, 6:05:48 AM2/17/18
to SWI-Prolog
Hello forum. I have a question. 
I have something like this written:

transportation(miami, plane).
transportation(toronto, car).
transportation(utah, plane).
transportation(newyork, car).
transportation(england, boat).
transportation(india, boat).

price(miami, 500.00).
price(toronto, 300.00).
price(utah, 600.00).
price(newyork, 400.00).
price(england, 900.00).
price(india, 1500.00).

and I want the user to type their preference of travel (plane, car, boat), so that the system could give them the possible destinations to choose from. Note that I ask the user multiple questions consequently and i don't want them to press space bar in order to show all the possible destinations.

write("What mean of transportation will you wish to use? (options: plane, car, boat)"),nl,
read(InputT),nl,
transportation(OutputT,InputT),nl,
write(OutputT),nl,

        write("What's your badget?"),nl,
read(InputP),nl,
price(OutputP, InputP),nl,
write(OutputP),nl.



it runs smoothly but the output is only the first of each category (when user selects plane, it is always and only miami etc.)

I would like the system 1) to find all the available destinations 
                                     2) store them somewhere in order to proceed to the next question (this time with some filter from the previous question. For example if the user types car I want the system to show only Toronto and NewYork and then when it comes to the next question about pricing , I want the system to only process the question for the destinations with car. 

Im new to prolog don't hate me if it's too simple. Thanks forum, cheers.

Boris Vassilev

unread,
Feb 17, 2018, 7:07:23 AM2/17/18
to i.quot...@gmail.com, SWI-Prolog
Are you hoping for someone to give you a pointer, or a complete solution?

Save our in-boxes! http://emailcharter.org

--
You received this message because you are subscribed to the Google Groups "SWI-Prolog" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/swi-prolog.
For more options, visit https://groups.google.com/d/optout.

i.quot...@gmail.com

unread,
Feb 17, 2018, 9:59:06 AM2/17/18
to SWI-Prolog
Hello Boris, I could use anything right now, thank you.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to swi-prolog+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages