[vox-tech] entering a prolog program?
Chanoch (Ken) Bloom
kbloom at gmail.com
Sat Nov 20 17:32:55 PST 2010
On Fri, 2010-11-19 at 20:05 -0800, Brian Lavender wrote:
> Can you type in axioms into prolog from the command line? All I seem to
> be able to do is load a program and query it.
>
> Can I just enter the following program at the prolog prompt?
>
> factorial(0,1).
>
> factorial(A,B) :-
> A > 0,
> C is A-1,
> factorial(C,D),
> B is A*D.
>
>
> All I seem to be able to do is load it. I am using SWI prolog.
>
> $ swipl
> ?- ['factorial.pl'].
> true.
>
> If I try the following, I get an error.
>
> ?- factorial(0, 1).
> ERROR: toplevel: Undefined procedure: factorial/2 (DWIM could not correct goal)
Typing [user]. the way you typed ['factorial.pl']. will enter an
interactive rule entry mode. When you're finished with that mode, hit
Ctrl-D to return to query mode.
--Ken
More information about the vox-tech
mailing list