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

  • Home
  • SEARCH
  • 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 6721919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:23:09+00:00 2026-05-26T09:23:09+00:00

I am implementing a family tree using Strawberry Prolog (what the computer labs have

  • 0

I am implementing a family tree using Strawberry Prolog (what the computer labs have at my school) and would like get rid of the duplicate answers. The findall function works in Strawberry Prolog which put all the answers in a list, but I believe setof does not exist with this compiler. I could either switch compilers or add the setof-function to this one. I think the latter would be a better learning experience, but I have no idea where to start.

Does anyone happen to know the code behind the setof function in other compilers and how to convert this to Strawberry Prolog? Or is there a function similar to setof already in Strawberry Prolog?

Thanks.

  • 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-26T09:23:10+00:00Added an answer on May 26, 2026 at 9:23 am

    You can simply sort the output of findall. Of course implementing setof it’s a much more rewarding path, but definitely not simple. Here source from SWI-Prolog:

    %%      setof(+Var, +Goal, -Set) is semidet.
    %
    %   Equivalent to bagof/3, but sorts the   resulting bag and removes
    %   duplicate answers. We sort  immediately   after  the  findall/3,
    %   removing duplicate Templ-Answer pairs early.
    
    setof(Templ, Goal0, List) :-
        '$free_variable_set'(Templ^Goal0, Goal, Vars),
        (   Vars == v
        ->  findall(Templ, Goal, Answers),
            Answers \== [],
            sort(Answers, List)
        ;   findall(Vars-Templ, Goal, Answers),
            (   ground(Answers)
            ->  sort(Answers,Sorted),
            pick(Sorted,Vars,List)
            ;   bind_bagof_keys(Answers,_VDict),
            sort(Answers, Sorted),
            pick(Sorted, Vars, Listu),
            sort(Listu,List) % Listu ordering may be nixed by Vars
            )
        ).
    

    As you can see, the basic it’s always findall…

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

Sidebar

Related Questions

implementing service something similar with tinyurl or bit.ly, I'm would like to expose service
When implementing a factory or simple factory, what would go against using a Type
I'm implementing unit tests for a family of functions that all share a number
implementing publishActivity in PHP using the REST API using this code: $activity = array(
When implementing Quicksort, one of the things you have to do is to choose
I implementing a EventQueue and get notified when AWTEvents are send. I wait till
While implementing a design using nested generic collections, I stumbled across those limitations apparently
When implementing HTTP services in node.js, there is a lot of sample code like
Implementing the basic algorithm using last array as a pivot in Java, is it
When implementing iterator using yield return , is there any difference between returning IEnumerator

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.