Download Flora-2: User's Manual
Transcript
10
MULTIFILE PROGRAMS
35
is perfectly acceptable and is more efficient than
?-
member(f(a), [f(b),f(a)])@prologall basics.
Flora-2 provides a special primitive, p2h{...,...}, which converts terms to and from the HiLog
representation, and the programmer can use it in conjunction with @prolog() to achieve a greater
degree of control over argument conversion. This issue is further discussed in Section 11.3.
Calling Flora-2 from Prolog
10.8
Since Prolog does not understand Flora-2 syntax, it can call only predicates defined in Flora-2
programs. To call predicates defined in Flora-2 programs, they must be imported by the Prolog
program.
10.8.1
Importing Flora-2 Predicates into Prolog Shell
To import a Flora-2 predicate into Prolog shell, the following must be done:
• The query
— ?- [flora2], bootstrap flora.
must be executed first.
• One of the following flImport queries must be executed in the shell:
| ?- flImport flora-predicate/arity as xsb-name( , ,..., )
from filename >> flora-module-name
| ?- flImport flora-predicate/arity as xsb-name( , ,..., )
from flora-module-name
We will explain shortly which flImport query should be used in what situation.
Note: If Flora-2 is installed outside of the XSB directory structure, then you must let Prolog
know the location of your distribution of Flora-2 . This is done by executing the prolog instruction
asserta(library directory(path-to-flora)). For instance
?- asserta(library_directory(’/home/me/flora2’)).
before calling any of the Flora-2 modules. Observe that asserta and not assert must be used.
10.8.2
Calling Flora-2 from a Prolog Module
To call Flora-2 from within a Prolog program, say test.P, the following must be done:
1. The query