Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6841167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T23:56:00+00:00 2026-05-26T23:56:00+00:00

So here it is, for my sudoku project I have a list, such as

  • 0

So here it is, for my sudoku project I have a list, such as :

L = [_G1-0:0:0,_G19-0:6:2,_G22-0:7:2,_G25-0:8:2].

and I want to filter this to get only the free variables :

[_G1, _G19, _G22 and _G25].

So wanting that, I wrote this predicate :

remove_position([], []) :- !.
remove_position([X-_|Xs], [X|Rs]) :- remove_position(Xs, Rs).

When calling

?- remove_position(L, Result).

SWI-Prolog answers

false.

So I edited the predicate a little :

remove_position([], []) :- !.
remove_position([X-_:_:_|Xs], [X|Rs]) :- remove_position(Xs, Rs).

and now it works as expected :

?- remove_position(L, Result).
Result = [_G1, _G19, _G22, _G25].

Still, I can’t see what’s wrong with the first one, for me, SWI-Prolog should match 0:0:0 with _ just as well as with _:_:_. Is there something I do not get ? Or is it a SWI-Prolog bug ?

Thanks for any enlightenment !

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T23:56:01+00:00Added an answer on May 26, 2026 at 11:56 pm

    When you have a term _G1-2:3:4 without any parentheses, you have to consider the associativity and precedence of the operators in order to find out how the term is parsed.

    The term _G1-2:3:4 is the same as (_G1-2):(3:4), not _G1-(2:3:4), and so the unification of _G1-2:3:4 and X-_ fails.

    If you add parentheses to your terms, like _G1-(2:3:4), then your original remove_position/2 predicate will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm doing a Sudoku solver and for that I want my JTextFields to only
Here is my code...I have two dimensional matrices A,B. I want to develop the
Here is a complete example. I want to forbid using A::set from objects casted
Here's what I want to do: Given a table PeopleOutfit (id int primary key,
Here's the method. I want to know if I am violating any best practices
Here's a Clone() implementation for my class: MyClass^ Clone(){ return gcnew MyClass(this->member1, this->member2); }
I was trying to model my project based on this project at Github. public
I'm making a Sudoku program in java to learn some algorithms so I want
Here's the basic setup: I have a thin bar at the top of a
Here is the problem that I am trying to solve. I have two folders

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.