recategorized by
1,196 views
3 votes
3 votes

Which of the following prolog programs correctly implement “if G succeeds then execute goal P else execute goal $\theta$”?

  1. if-else (G, P, $\theta$):-!,call(G), call(P). if-else (G,P, $\theta$) :- call($\theta$).
  2. if-else (G, P, $\theta$):-call(G), !, call(P). if-else (G,P, $\theta$) :- call($\theta$).
  3. if-else (G, P, $\theta$):-call(G), call(P), !. if-else (G,P, $\theta$) :- call($\theta$).
  4. All of the above
recategorized by

1 Answer

0 votes
0 votes

The syntax of If-then-else in prolog goes the following way

(A $\rightarrow$ B ; C ) :

          call(A),

          !,

          call(B)

(A $\rightarrow$ B ; C ) :

          call(C)

So according to the above syntax, the correct answer will be 

(B)  if-else (G, P, $\Theta$) :- call(G), !, call(P). if-else (G, P, $\Theta$) :- call($\Theta$).

Answer:

Related questions

3 votes
3 votes
2 answers
2
2 votes
2 votes
3 answers
3
go_editor asked Jul 7, 2016
6,400 views
The optimal solution of the following assignment problem using Hungarian method is$\begin{array}{|l|l|l|l|} \hline \text{ } & \text{I} & \text{II} & \text{III} & \text{IV...
3 votes
3 votes
1 answer
4