Pages: [1]
Print
Author Topic: example Prolog questions  (Read 2227 times)
Laurie Murphy
Administrator
Newbie
*****
Posts: 709


« on: December 07, 2007, 03:39:15 PM »

Here are some prolog questions I have asked in the past:

1.   Explain the two approaches to matching goals to facts in a database.  Which approach did the designers of Prolog choose to use?
2.   Explain what is wrong with the Prolog statement Total is Total + Number.
3.   Describe three deficiencies of Prolog.
4.   Name three applications of logic programming.
5.   What symbol is used to represent the cut operator in Prolog?  What is the purpose of using a cut?
6.   Is Prolog case sensitive?  Explain. 
7.   What value will be assigned to M using the Prolog rules listed below and the question test(o,[o,h,a,o,i,s,i,o],t,M).  What do the rules accomplish in general? 

Code:

test(_,[],_,[]).

test(X,[X|L],A,[A|M]):-
     test(X,L,A,M).

test(X,[Y|L],A,[Y|M]):-
  X \= Y,
  test(X,L,A,M).


Remember the '_' means you don't care what the value of the argument is.       


Logged
Pages: [1]
Print
Jump to: