question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected result with findall/3

See original GitHub issue

For the following program in http://tau-prolog.org/sandbox/

test :-
    findall([A,_],p(A,_),L),
    write(L),
    nl.

p(a,b).
p(c,d).
p(e,f).

the query

test.

gives

[[a,__2],[c,__2],[e,__2]]

whereas the expectation is somtehing like

[[a,_2],[c,_3],[e,_4]]

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
pmouracommented, Feb 7, 2022
2reactions
jariazavalverdecommented, Feb 7, 2022

@pmoura Try with a variable not in the goal. You should get something like:

?- assertz(f(1)).
true.

?- assertz(f(2)).  
true.

?- findall((B,A), f(A), [(B1,1),(B2,2)]), B1 \== B2.
false.
Read more comments on GitHub >

github_iconTop Results From Across the Web

Python findall returns unexpected results - Stack Overflow
re.findall returns a tuple which contains all results () captures. Your have 9 () in your regular pattern, so you got a tuple...
Read more >
prolog_notes/README.md at master - GitHub
findall (Template, Goal, Instances) is true iff Instances unifies with the list of values to which a variable X not occurring in Template...
Read more >
FindAll with Regex returns unexpected range with bulleted text ...
When the text contains a "-" as bullet, the "-" is returned as part of the result when the beginning of the text...
Read more >
5 Common Hibernate Mistakes That Cause Dozens of ...
5 Common Hibernate Mistakes That Cause Dozens of Unexpected Queries ; 1 1. Not Initializing Lazily Fetched Associations. 1.1 Initialize all Required Associations....
Read more >
re — Regular expression operations — Python 3.11.1 ...
prog = re.compile(pattern) result = prog.match(string). is equivalent to ... re.findall(r'\bf[a-z]*', 'which foot or hand fell fastest') ['foot', 'fell', ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found