This commit is contained in:
Ingy döt Net 2013-10-27 22:24:23 +00:00
parent 6f050a029e
commit 776bba907c
3887 changed files with 59894 additions and 7280 deletions

View file

@ -0,0 +1 @@
multiply(A, B, P) :- P is A * B.

View file

@ -0,0 +1,3 @@
go :-
multiply(5, 2, P),
format("The product is ~d.~n", [P]).

View file

@ -0,0 +1,3 @@
test_multiply :-
multiply(5, 2, 10), % this will pass
multiply(3, 4, 11). % this will not pass

View file

@ -0,0 +1,6 @@
:- use_module(library(function_expansion)).
user:function_expansion(multiply(A, B), P, P is A * B). % "function" definition
go :-
format("The product is ~d.~n", [multiply(5, 2)]).

View file

@ -0,0 +1,3 @@
go :-
A is 5*2,
format('The product is ~d.~n', [A]).