Explain with an example what is “Setof” predicate in Prolog?
Answer / chaitanya
In Prolog, “Setof” predicate can be used to find out all the solutions of a predicate. For example, you have this database:
Guru99 (SAP, Testing Tools)
Guru99 (PHP, Perl)
And if you want to find the solutions of Guru99 (X, Y). We can enter
Setof ([ X,Y] , Guru99 (X,Y), Z).
Z = [[ SAP , Testing Tools], [ PHP, Perl] ]
Is This Answer Correct ? | 0 Yes | 0 No |
What is the output of the following statement? * (setf meals ‘(breakfast lunch tea dinner)) * (cons (first meals) (last meals)) a) Breakfast b) Lunch c) Dinner d) Both a & c
Which is present in the writer procedure for arrays in LISP? a) Setf b) Aref c) Fref d) Both a & b
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
. What is the output of the given statement? * (defstruct employee (length-of-service 0) (payment ‘salary)) * (setf employee-example (make-employee)) * (employee-length-of-service employee-example) a) T b) NIL c) 0 d) Error
What is the output of the given statement? * (defclass article() ((title :accessor article-title :initarg :title) (author :accessor article-author :initarg :author))) a) Article b) c) d) None of the mentioned
What is the programming structure for LISP?
Which can build new lists by depositing pointers in free boxes? a) Do b) Dobuild c) Cons d) None of the mentioned
Which creates reader procedures for getting things out of an instance fields? a) Structure in LISP b) Defstruct c) Class d) Object
Which checks the evaluated key form against the unevaluated keys using EQL? a) COND b) CASE c) NIL d) SETF
Which exploit the fact that lisp forms are just expressions meant to be evaluated? a) List b) Procedure c) Macro d) None of the mentioned
Which has a template that calls for particularly peculiar argument evaluation? a) COND b) Consequent c) Trigger d) Sphere
Explain what is List structures in Prolog?