[vox-tech] entering a prolog program?
Brian Lavender
brian at brie.com
Fri Nov 19 20:05:37 PST 2010
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)
brian
--
Brian Lavender
http://www.brie.com/brian/
"Program testing can be used to show the presence of bugs, but never to
show their absence!"
Professor Edsger Dijkstra
1972 Turing award recipient
More information about the vox-tech
mailing list