Questions tagged [prolog-setof]

setof/3 is a built-in predicate of ISO Prolog. It determines the set of solutions as a list for each different instantiation of the free variables.

69 questions
0
votes
1 answer

Prolog bagof, setof, findall predicates

How do I query database facts with 3 or more attributes in Prolog using bagof, setof. An example I have a defined a database students(name, grade,sport,gender). I want find a list of students that play a particular sport, say cricket. My current…
0
votes
0 answers

Prolog setof/3 not returning all elements

I'm making a list of all the breed of dog sizes in my database, e.g. breed(beagle,medium, hunting). breed(bassets,medium, hunting). breed(labrador,large, guideDogs). breed(germanShepards,large,…
ildsarria
  • 281
  • 3
  • 10
0
votes
1 answer

Prolog ensure a rule's return parameters are unique and in canonical order

I have some data declared in a Prolog file that looks like the following: gen1(grass). gen1(poison). gen1(psychic). gen1(bug). gen1(rock). ... gen1((poison, flying)). gen1((ghost, poison)). gen1((water, ice)). ... weak1(grass,…
xenrelay
  • 111
  • 1
  • 9
0
votes
1 answer

Prolog - Using Bagof

I've been stuck on a past paper question while studying for my exams. The question is: https://gyazo.com/ee2fcd88d67068e8cf7d478a98f486a0 I figured I've got to use findall/bagof/setof because I need to collect a set of solutions. Furthermore, setof…
user3186023
0
votes
0 answers

No permission to satisfy static procedure setof/3 in prolog

I'm using SWI prolog and was wondering how I can use setof in my source code. I have a file: prolog_example.pl which has some facts: stuff(hello,1,2,west). stuff(goodbye,3,4,west). stuff(how,5,6,north). stuff(are,7,8,north). canMatch(X,Y):- …
Alex
  • 2,145
  • 6
  • 36
  • 72
0
votes
0 answers

Prolog: "\+ memberchk" inside "setof"

I have some Prolog code of the following form: setof(Element,some_function(P,Element,C),Elements) such that all instantiations of term Element in solution to some_function are collected in list Elements. I now want to improve this with memberchk…
R1414
  • 17
  • 6
0
votes
1 answer

Prolog Find All Predicate

I am trying to find all the brothers of a person.. I have created the following rule.. find_all_brothers(Z):- findall(X,brother(X,Z),X0),write(X0). This works however, if a person has more then one brother then it will only find a single…
bdavies6086
  • 382
  • 1
  • 5
  • 19
0
votes
2 answers

Simple Prolog setof

this is simple yet cannot seem to grasp it I have these "colors" color(blue). color(red). color(white). using setof I need to get all possible combinations of these colors in a list It would be great if you can provide a brief explanation. I tried…
user3241846
  • 643
  • 3
  • 9
  • 26
0
votes
1 answer

setof/3 and NAF

so I have a set of facts: course(cs61, "intro to cs") ... course(cs62b, "data structure") ... grade(adam, cs61, spring11, "A") ... grade(chrisitian, cs61, fall2010, "A-") I need to define a predicate good_standing(Student) to determine…
SDEZero
  • 363
  • 2
  • 13
1 2 3 4
5