Tags:
create new tag
, view all tags
+++ Prolog examples Plugin

[ move all devel chit chat to PrologSamplePluginDev ]

This plugin nicely formats a Prolog piece of code, together with its query results.

His brother is the PerlSamplePlugin.

TODO:

  • Apply a timeout to the Prolog execution (spawn a delayed killer process)

Usage example

You type: You get: If correctly installed:
 
%PROLOGSAMPLE{" 
knows(andrea,automi). 
knows(annalisa,karnaugh). 
prerequisiteof(automi,karnaugh). 
prerequisiteof(karnaugh,boole). 
mayknow(X,U) :- knows(U,Y), 
   prerequisiteof(Y,X). 
mayknow(X,U) :- knows(U,X)."  
query="?- mayknow(TOPIC,USER)."  
vars="TOPIC,USER"}%  
Initial KB
 
knows(andrea,automi). 
knows(annalisa,karnaugh). 
prerequisiteof(automi,karnaugh). 
prerequisiteof(karnaugh,boole). 
mayknow(X,U) :- knows(U,Y), 
   prerequisiteof(Y,X). 
mayknow(X,U) :- knows(U,X).
Query:
?- mayknow(TOPIC,USER).
Result:
found solutions: 
   TOPIC = karnaugh 
   USER = andrea 
found solutions: 
   TOPIC = boole 
   USER = annalisa 
no more solutions 
 
%PROLOGSAMPLE{" knows(andrea,automi). knows(annalisa,karnaugh). prerequisiteof(automi,karnaugh). prerequisiteof(karnaugh,boole). mayknow(X,U) :- knows(U,Y), prerequisiteof(Y,X). mayknow(X,U) :- knows(U,X)." query="?- mayknow(TOPIC,USER)." vars="TOPIC,USER"}%

Settings

  • One line description, is shown in the TextFormattingRules topic:
    • Set SHORTDESCRIPTION = This plugin nicely formats a Prolog piece of code, together with its query results.

Installation

  • Unzip the PrologSamplePlugin.zip file in your TWiki installation directory.
  • Install the Language::Prolog Perl module attached to it (it complains less respect to the CPAN version.) in your Perl @INC path.

If the installation is correct you will see a nice table showing the code, its value and stdout/stderr near the example.

-- TWiki:Main.AndreaSterbini - 27 Nov 2001

Edit | Attach | Watch | Print version | History: r4 < r3 < r2 < r1 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r4 - 2005-08-23 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.