Explain why matching variable is important in Prolog? What is the method to match variables?



 Explain why matching variable is important in Prolog? What is the method to match variables?..

Answer / chaitanya

In Prolog, in order to process the elements of a list, we have to match them to variables. The method for doing is
We get the head by matching it to a variable
By calling a predicate with the variable, it processes the head
Until you get an empty list repeat the above steps

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More AI Languages Interview Questions

What is the output of the given statement? * (defstruct person (sex nil) (personality ‘nice)) * (setf person-instance-1 (make-person)) * (setf person-instance-2 (make-person :sex ‘female)) * (person-p ‘(this is a list — not a person instance)) a) Female b) Nice c) T d) Nil

1 Answers  


Explain what is slot and what are the most commonly used slot options?

1 Answers  


 Mention what is the difference between = and = = in Prolog?

1 Answers  


 Which symbol holds the first element and also an index in LISP? a) Nail b) Tail c) Initial d) All of the mentioned

1 Answers  


Which has a template that calls for particularly peculiar argument evaluation? a) COND b) Consequent c) Trigger d) Sphere

1 Answers  






What is the output of the following statement? * (defun (input-list) (if (endp input-list) nil (cons ( (first input-list)) ( (rest input-list))))) a) Procedure b) Transforming c) Input d) Error

1 Answers  


 Which can be represented in bytes in LISP? a) Boxes and pointers b) Lists c) Lisp d) None of the mentioned

1 Answers  


 What is the output of the following statement? * ‘(first (first (rest (rest ((a b) (c d) (e f)))))) a) a b) b c) ab d) (FIRST (FIRST (REST (REST ((A B) (C D) (E F))))))

1 Answers  


Which keyword is used to define the method? a) Defun b) Destruct c) Demake d) Defmethod

1 Answers  


 What is the output of the given statement? * (defstruct circle (radius 0)) * (defun area (figure) (cond ((circle-p figure) (* pi (expt (circle-radius figure) 2))))) * (setf circle (make-circle :radius 11)) * (area circle) a) 44 b) 380 c) 382 d) 380.132

1 Answers  


 Which hides details behind abstraction boundaries? a) Procedures b) Procedure abstraction c) Recursion d) Both a & b

1 Answers  


 Which is uses their arguments to build intermediate forms and evaluating them to produce a value? a) Backquote b) Macros c) List d) Procedures

1 Answers  


Categories