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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:08:01+00:00 2026-06-02T13:08:01+00:00

I am new to prolog, and using BProlog. I have been reading some example

  • 0

I am new to prolog, and using BProlog.

I have been reading some example program to execute query on group of related data. But in order to infer from facts with similar structure, they wrote many predicates like search_by_name,search_by_point, which are partly duplicated.

% working search in example
search_by_name(Key,Value) :-
    Key == name,
    sname(ID,Value),
    point(ID,Point),
    write(Value),write(Point),nl.

And when I try to replace them with a more general version like this:

% a more general search I want to write
% but not accepted by BProlog
search_by_attr(Key,Value) :-
    Key(ID,Value),
    sname(ID,Name),
    point(ID,Point),
    write(Name),write(Point),nl.

error arised:

| ?- consult('students.pl')
consulting::students.pl
** Syntax error (students.pl, 17-21)
search_by_attr(Key,Value) :-
        Key<<HERE>>(ID,Value),
        sname(ID,Name),
        point(ID,Point),
        write(Name),write(Point),nl.

1 error(s)

Am I doing it the wrong way, or is such subtitution impossible in prolog?

code and example data can be found at https://gist.github.com/2426119

  • 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-06-02T13:08:01+00:00Added an answer on June 2, 2026 at 1:08 pm

    I don’t know any Prolog that accept variables functors.
    There is call/N, or univ+call/1.

    search_by_attr(Key,Value) :-
        call(Key, ID, Value), % Key(ID,Value)
        ...
    

    or

    search_by_attr(Key,Value) :-
        C =.. [Key, ID, Value], % univ
        call(C),                % Key(ID,Value)
        ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to prolog programming and have been told in a tutorial to
I'm new to Prolog and trying to do a program to check if some
I am new to Prolog and I have some probably simple issue with a
I am new to Prolog and I have so far learned how to define
I'm new to Prolog and stuck on some programming homework. one of them should
I am new in Prolog and I am stucked in a problem. I have
I'm new to Prolog. Using this basic 'database' structure, I thought I would be
I'm brand new to Prolog. I am simply trying to get some output from
(Pardon if my terminology is wrong... I'm new to Prolog.) Suppose you have a
I am completely new to Prolog and trying some exercises. One of them is:

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.