Understanding the clause / 2 predicate

I'm currently trying to learn some Prolog (using ECLiPSe). From time to time I come across a predicate of the / 2 sentence, but I don’t understand what it is used for. I read a few links (like this one ), but I still don’t understand in which case this might be useful. Can someone provide me with a simple example or explanation of this?

+3
source share
2 answers

This predicate allows metaprogramming, i.e. talk about your prolog program.

SWI-Prolog uses the clause/2in, ao predicate explain:

?- explain(member).
"member" is an atom
        Referenced from 12-th clause of pce_meta:pce_to_pl_type/3
lists:member/2 is a predicate defined in
        c:/program files/swi-prolog/library/lists.pl:81
        Referenced from 1-th clause of prolog_dialect:source_exports/2
        Referenced from 1-th clause of pce_config:term_description/2
        Referenced from 1-th clause of pce_config:config_attribute/2
        Referenced from 1-th clause of pce_config:load_config_key/2
        Referenced from 1-th clause of pce_config:term_description/3
        Referenced from 1-th clause of pce_config:current_config_path/1
        Referenced from 4-th clause of persistent_frame:has_specifier/1
true.

. , Prolog.

Prolog . " " .

+3

- quine: b

quine :-
    clause(quine, A),
    portray_clause((quine:-A)).

, , , larsmans

+1

All Articles