Explain what is the difference between bagof/3 and setof/3 predicate in Prolog?



Explain what is the difference between bagof/3 and setof/3 predicate in Prolog?..

Answer / chaitanya

Setof/3 is similar to bagof/3 and the difference between is that bagof/3 leaves all repeated solutions while setof/3 removes them.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More AI Languages Interview Questions

What is the general pattern that shows how the various parts of an expression fit together? a) Template b) Pattern c) Match d) Both a & b

2 Answers  


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

1 Answers  


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

1 Answers  


 Which process helps to build large and complicated programs in LISP? a) Macros b) Procedure abstraction c) Defun d) None 

1 Answers  


What is the output of the following statement? * (setf p .6) * (cond ((> p .75) ‘very-likely)((> p .5) ‘likely)((> p .25) ‘unlikely)(t ‘very-unlikely)) a) Very-likely b) Likely c) Unlikely d) Very-unlikely

1 Answers  






 What is the output of the given statement in LISP? * (setf abc ‘(a b c) xyz ‘(x y z)) * (setf bc (rest abc)) * bc a) A b) B c) C d) BC

1 Answers  


Which do not evaluate their arguments in LISP? a) List b) Procedure c) Setf d) Macros

1 Answers  


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)) a) Person :sex female :personality nice b) Person :sex c) Sex:Female d) None of the mentioned

1 Answers  


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

1 Answers  


Which is used to represent the prompt in lisp? a) # b) $ c) & d) *

1 Answers  


What is the output of the following statement? * (defun make (title author) (list (list ‘title title) (list ‘author author))) * (setf book (make ‘(Common Lisp) ‘(Guy steele))) a) Common Lisp b) Guy steele c) Make d) ((TITLE (COMMON LISP)) (AUTHOR (GUY STEELE)))

1 Answers  


What is the output of the given statement in LISP? * (setf abc ‘(a b c) xyz ‘(x y z)) * abc a) A b) B c) ABC

1 Answers  


Categories