Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Simple function in Prolog

Posted on 2013-06-06
1
Medium Priority
?
283 Views
Last Modified: 2013-07-20
I want to write such a function in PROLOG that when i run hulk(2,P)  in the terminal , it gives me :
NO  
I write the code as below. BUt it doesn't work.
hulk(2,P) :- P is NO.

I tried also below
hulk(2,P) :- P is [NO].
But it doesn't work.
When i compiled it , I take the warning:
Warning: /home/samil/hw6.pl:1:
      Singleton variables: [No]

WHen i run it , i take the error:
ERROR: is/2: Arguments are not sufficiently instantiated
HOw to do it?
0
Comment
Question by:codeBuilder
1 Comment
 
LVL 24

Accepted Solution

by:
fridom earned 2000 total points
ID: 39228291
Try:
hulk(X,P) :-
       writef('NO'), nl.

call it with:

X=2, hulk(X,P).
false.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

782 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question