findall/3 is a built-in predicate of ISO Prolog.
Questions tagged [prolog-findall]
66 questions
0
votes
1 answer
Prolog problem with findall how to construct a solution of a list which is a pair (element, list_of_elements)
I'm trying to resolve a problem but I don't know how to manage properly the predicate findall.
The idea is the next one.
We have a table and some blocks arranged in a stack on the table.
This could be a example of a given situation:…

OnlyDavies
- 123
- 2
- 8
0
votes
1 answer
Prolog multiple unifications to one variable
I need to unify all terms in database to one variable.
For given code:
man('a').
man('b').
main :-
prompt(_, ''),
man(X),
write(X),
nl,
halt.
I get output:
a
I need to get something like:
['a','b']
Is it…

nocturne
- 627
- 3
- 12
- 39
0
votes
2 answers
Merging elements of tuples in a list in Prolog
I need to create a list from a knowledgebase that could look like this:
fact1(3,3).
fact1(2,3).
fact1(3,5).
fact1(2,2).
fact1(2,10).
fact1(3,1).
fact1(1,1).
fact1(1,6).
fact2(3,a,b)
fact2(2,c,d)
fact2(1,e,f)
That list needs to contain tuples with…

HappyHippo
- 152
- 3
- 11
0
votes
0 answers
Prolog - findall returns a list of uninstantiated variables rahter than values
I am writing a Checkers game in Prolog, and I want to write a predicate to print all possible moves.
I have a predicate who checks all the legal moves than can be made -
is_move_legal(Board,p(X1,Y1),p(X2,Y2),DoEat, Player):-
Player = w, …

Assaf
- 1,112
- 4
- 14
- 35
0
votes
2 answers
Prolog - getting a list of friends of friends
I'm struggling to get a decent result,
I have some friends,
friend(a,b).
friend(a,b2).
friend(a,b3).
friend(b,c).
friend(c,d).
friend(d,e).
friend(e,f).
Using findall(X,friend(a,X),List) I'm getting all direct friends of a
List=[b,b2,b3].
For…

Daniel Fialho
- 23
- 3
0
votes
1 answer
Counting list size resulting from a findall not working in Prolog
I obtain a specific list using findall, and then want to count the number of elements in it.
i.e.
huntingbreeds(List) :-
findall(Breedname, breed(Breedname,_,hunting), List).
This returns a need list of hunting dogs from my database [beagle,…

ildsarria
- 281
- 3
- 10
0
votes
2 answers
findall/3 incorrectly evaluating to false
I'm creating a program which should allow search through a graph, but the function which should return a list of successor nodes is failing when a call to findall/3 evaluates to false. When I try the findall function on its own outside of the…

bendl
- 1,583
- 1
- 18
- 41
0
votes
0 answers
What does this error mean? Exception: (13) setup_call_catcher_cleanup
What does this error mean? And how do I solve it? (In theory of course.)
The program is to complex to put here.
ERROR: Out of global stack
^ Exception: (13) setup_call_catcher_cleanup('$bags':'$new_findall_bag', '$bags':findall_loop(_G15784496,…
user3636673
0
votes
1 answer
Sort lists from shortest to longest
I've recently picked up prolog and am trying to make a program to find a solution for the famous puzzle Knight's Tour
[found here]
Using the Warnsdorff algorithm i'm trying to find all the possible moves that can be made from a specific spot on the…

vega2015
- 119
- 3
- 11
0
votes
1 answer
Prolog Using findall/3 on a Matrix
I have the following matrix in my SWI prolog;
matrix(1,[ [*,*,*,*,*,*,*,*,*,*,*,*],
[*,*,*,spots(2,4),spots(2,5),*,*,*,*,spots(2,10),spots(2,11),*],
…
user6066919
0
votes
1 answer
How to use tranpose and findall to print all the variables in a predicate
I wanted to know how I could use tranpose and findall to list all the variables in a predictate and display it as matrix?
so this is the predicate with all the variables.
across(2,4,2,4).
across(2,10,2,4). …

user6105558
- 49
- 7
0
votes
1 answer
Prolog combining predicates
Just a small question about Prolog. Say I have used the built in predicate findall/3 to obtain a list and used the variable X as my output.
I'm wondering how I could then use this list in another predicate such as last/2 to find the last element of…

ZazzyCola
- 21
- 4
0
votes
1 answer
Prolog findall existential quantifier
I have a problem with a problem in Prolog.
Here's some of the code I use.
has_same_elements([X|_],Y) :-
permutation(X,Xnew),
member(Xnew,Y), !.
has_same_elements([_|Tail],Y) :-
has_same_elements(Tail,Y).
This gets two lists of…

Perow
- 9
- 3
0
votes
1 answer
swi prolog findall(\+z-AS-Sesio-Hsemana u-CU-Hsemana, between(1,NH,Sesio), C) gives error
I'm trying to use 2 templates in findall but I'm getting error because of the ' ', between first template and second, it asks me to put an operand, I put + then it shows the C as template1 '+' template2 but I don't want the + to appear on C.
Also…

Daniel Roca Lopez
- 574
- 5
- 22
0
votes
0 answers
Prolog : Creating a list with findall using user input
So my problem is the following:
I must create a list , using the findall / bagof / setof commands.
Here is my data file:
musico('R. Stevie Moore').
musico('Lane Steinberg').
musico('Yukio Yung').
musico('Jessie Evans').
musico('Bettina…

eXistanCe
- 735
- 1
- 9
- 25