a :- b, c, d:- e f.
happy(X):- a , b.
happy(X):- hasmoney(X) & has_friends(X).
fun(fish):- blue(betty), bike(yamaha).
likes(john,mary).
likes(john,trains).
likes(peter,fast_cars).
- likes(Person1,Person2):-
- hobby(Person1,Hobby),
hobby(Person2,Hobby).
hobby(john,trainspotting).
hobby(tim,sailing).
hobby(helen,trainspotting).
hobby(simon,sailing).
?- likes(john,trains).
?- likes(helen,john).
?- likes(tim,helen).
?- likes(john,helen).
a(X):-
b(X), c(X), d(X).
a(X):-
c(X), d(X).
a(X):-
d(X).
b(1).
b(a).
b(2).
b(3).
d(10).
d(11).
c(3).
c(4).
Given the query ?- a(X). Indicate the successive variable bindings that the variable X gets when the above query is run. Separate bindings by a comma (ie. 1,3,5.....)
PROGRAM MAIN(INPUT, OUTPUT) ;
PROCEDURE P(V: INTEGER) ;
VAR
X: INTEGER ;
PROCEDURE Q(V: INTEGER) ;
BEGIN
X := V ;
WRITELN("In Q -- X = ", X:2, ", V = ", V:2) ;
END ;
PROCEDURE R(V: INTEGER) ;
VAR
X: INTEGER ;
PROCEDURE S(V: INTEGER) ;
BEGIN
X := V ;
Q(V+1) ;
WRITELN("In S -- X = ", X:2, ", V = ", V:2) ;
END ;
BEGIN
X := V ;
S(V+1) ;
WRITELN("In R -- X = ", X:2, ", V = ", V:2) ;
END ;
BEGIN
X := V ;
R(V+1) ;
WRITELN("In P -- X = ", X:2, ", V = ", V:2);
IF (V < 45000) THEN
P(48048) ;
END ;
BEGIN
P(43680) ;
END .
procedure BIGSUB;
integer GLOBAL;
integer array LIST[1..2];
procedure SUB (PARAM);
integer PARAM; (declaration of type for the parameter PARAM)
begin
PARAM := 3;
GLOBAL := GLOBAL +1;
PARAM := 5;
end (SUB);
begin
LIST[1] := 2;
LIST[2] := 2;
GLOBAL := 1;
SUB(LIST[GLOBAL]);
end (BIGSUB);
procedure Main;
procedure A;
procedure B;
begin { B }
<============ 1
end; { B }
procedure C;
begin { C }
B;
end; { C }
begin { A }
C;
end; { A }
begin { Main }
A;
end; { Main }