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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T01:14:44+00:00 2026-06-13T01:14:44+00:00

I am working on a simple prolog program. Here is my problem. Say I

  • 0

I am working on a simple prolog program. Here is my problem.

Say I already have a fact fruit(apple).

I want the program take a input like this ?- input([what,is,apple]).

and output apple is a fruit

and for input like ?-input([is,apple,a,fruit])

instead of default print true or false, I want the program print some better phrase like yes and no

Can someone help me with this?

My code part is below:

input(Text) :-
   phrase(sentence(S), Text), 
   perform(S).
   %...
sentence(query(Q))     --> query(Q).

query(Query) --> 
   ['is', Thing, 'a', Category],
   { Query =.. [Category, Thing]}.

% here it will print true/false, is there a way in prolog to have it print yes/no, 
%like in other language: if(q){write("yes")}else{write("no")}
perform(query(Q))     :- Q.   
  • 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-13T01:14:45+00:00Added an answer on June 13, 2026 at 1:14 am

    In Prolog there is a construct if/else:

    perform(query(Q)) :-
      (  Q
      -> write(yes:Q)
      ;  write(no)
      ), nl.
    

    When I need a stricter control on output formatting, I use format.
    Not very friendly, but offers most of the usual options…

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

Sidebar

Related Questions

I'm working on simple image manipulation program. I'm currently in phase where I have
I had a simple working (ASP.NET) Scenario here: 3 asp:RadioButtons that each have OnCheckedChanged
I have a working simple jquery drop-down menu . But problem is how can
Good Day, I have a simple working routine in Perl that swaps two words:
Working on a simple C program I'm stuck with an if test: int line_number
im working on a simple game like space invaders,and i got into a problem.
I have this simple working curl command: curl -k -d X-User=user -d X-Password=password https://12.12.12.21
Currently i am working in simple android app, I have tried to range of
I am working on simple login form. I have two text fields as user
Here is a simple working query without bind variables: select * from table1 where

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.