SDA SE Wiki

Software Engineering for Smart Data Analytics & Smart Data Analytics for Software Engineering

User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
teaching:labs:xp:2009a:prolog_questions [2009/02/04 14:55]
daniel.morales
teaching:labs:xp:2009a:prolog_questions [2018/05/09 01:59] (current)
Line 1: Line 1:
 +
 +
 +====== Questions about Prolog ======
 +
 +
 +  * **Q:** How do I find out, in which file(s) a predicate is actually defined?  ​
 +  * **A:** This can be simply done by using the built-in predicate_property/​2 with the property file(FileName).
 +
 +  /* * * * predicate_in_file(Head,​ File) * * * * 
 +   ​* ​
 +   ​* ​ Example:
 +   ​* ​  ?- predicate_in_file(Head,​ '​d:/​workspaces/​runtime-eclipseapplication/​pop/​qap.pl'​).
 +   ​* ​  Head = predicate_in_file(_,​ _) ;
 +   ​* ​  ​false. ​
 +   *
 +   */
 +  ​
 +  predicate_in_file(Head,​ File):-
 +    predicate_property(Head,​ file(File)).
 +
 +Note: In case of "​multifile"​ predicates (whose clauses are unioned from the contents of multiple files) the above gives the name of just one file, not of all :-( If you don't know what multifile predicates are and how to work with them, see the SWI-Prlog manual((Just type "​help."​ in the prolog console nd then "​multifile"​ in
 +the interactive manpage.)).
 +
 +====== Notes ======
 +
 +  * ''​listing(my_predicate/​3)''​ gives me the implementation of ''​my_predicate''​ with 3 parameters.
 +
 +
  
teaching/labs/xp/2009a/prolog_questions.txt · Last modified: 2018/05/09 01:59 (external edit)

SEWiki, © 2019