For Programmers: Free Programming Magazines  


Home > Archive > Prolog > January 2006 > Entering facts from the prompt -- newbie question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Entering facts from the prompt -- newbie question
Jonathan Bartlett

2006-01-10, 4:10 am

Is it supposed to be difficult to enter in facts from the prolog prompt?
It seems on the prolog systems I've looked at, you can only put facts
in files and consult the files. In gprolog you can use [user]. to enter
in facts, but that still seems strange.

Is there a standard way to enter facts from an interactive prompt?

If you were typing out a prolog listing for an example to someone else,
how do you separate the facts from the queries? Do you put ?- in front
of the queries? Do you specify that the facts should be in a separate file?

Thanks,

Jon
----
Learn to program using Linux assembly language
http://www.cafeshops.com/bartlettpublish.8640017
Marco Gavanelli

2006-01-10, 4:10 am

Jonathan Bartlett wrote:
> Is it supposed to be difficult to enter in facts from the prolog prompt?
> It seems on the prolog systems I've looked at, you can only put facts
> in files and consult the files. In gprolog you can use [user]. to enter
> in facts, but that still seems strange.
>
> Is there a standard way to enter facts from an interactive prompt?


One possibility is to use assert, which adds a new clause (which, in
particular, can be a fact).

> If you were typing out a prolog listing for an example to someone else,
> how do you separate the facts from the queries? Do you put ?- in front
> of the queries? Do you specify that the facts should be in a separate
> file?


Usually you write only the clauses (which can also be facts) in the
files, then you execute the query from the Prolog prompt.

You can also write queries in the file, but you typically do this when
you want things to happen at compile time, like, e.g., loading libraries.

Cheers,
Marco

--
http://www.ing.unife.it/docenti/MarcoGavanelli/
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com