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 6913567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:14:07+00:00 2026-05-27T09:14:07+00:00

How can I code member/2 that has determinism for the last element. Currently I

  • 0

How can I code member/2 that has determinism for the last
element. Currently I am using:

member(X,[X|_]).
member(X,[_|Y]) :- member(X,Y).

When I query the following:

?- member(X,[1,2]).
X = 1 ;
X = 2 ;
No

The interpreter continues searching after returning 2 since
there is still a choice point left. How could I implement member/2
so that this does not happen anymore?

But the full semantic of member/2 should be preserved, i.e.
answers such as:

 ?- member(X,Y)
 Y = [X|_1] ;
 Y = [_1,X|_2] ;
 etc..

Should still work as befor.

Bye

  • 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-27T09:14:07+00:00Added an answer on May 27, 2026 at 9:14 am
    member(B, [C|A]) :-
        member_(A, B, C).
    member_(_, A, A).
    member_([C|A], B, _) :-
        member_(A, B, C).
    

    Is the result of two listing calls on swi.

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

Sidebar

Related Questions

I am using XAMPP and was wondering if I can code my site to
I'm trying to build some image algebra code that can work with images (basically
I'm trying to write a class that has a generic member variable but is
I have a form that has a member that implements IDisposable but not IComponent
I'm trying to encode an object that has a member of type INetAddress to
One of my WCF functions returns an object that has a member variable of
I have 3 entities: RatedPrice, DailyPrice and UtilizePrice. Each entity has Code member. I
I currently have a Rails website that has some Prototype scripting in it. My
I am using a library that has a function that takes an array of
In C++ I have defined a class that has this as a member: static

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.