Database The Prolog Way |
Written by Mike James | |||||
Friday, 18 February 2022 | |||||
Page 4 of 4
The complete program is:
If you are using the downloaded version enter all of the clauses into the editor and compile the program.
If you are using the online version enter all of the clauses into the lefthand panel. Switch to the command line and enter:
Which produces the output (make sure you have table results ticked in the online version):
Note the double occurrence of paddington is due to this being the change of line. I admit that there is a bug that can cause time wasting inefficient journeys but you can fix it in no time at all. I hope you enjoy using this route finder but if you get lost then my advice is to ask a policeman... You can see that Prolog, and logic programming in general,require a big change in the way that you think about problems but it is often more effective than the apparently more direct procedural approach - something that is rarely stated but is very true. If you try to extend the tube program you will almost certainly have many a frustrating hour or two as your brain retrains itself to think in terms of logical assertions, but you will have a lot of fun on the way to a working program.
Robot cars - provably uncrashable? The Paradox of Artificial Intelligence Watson wins Jeopardy! - trick or triumph Fuzzy Logic And Uncertainty In AI The Greeks, George Boole and Prolog A Programmers Guide To LanguagesContents
To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin. <ASIN:0201403757> <ASIN:0262514451> <ASIN:0136070477> <ASIN:0136070477> <ASIN:193435659X> |
|||||
Last Updated ( Friday, 18 February 2022 ) |