Solved

Simple function in Prolog

Posted on 2013-06-06
1
273 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 500 total points
ID: 39228291
Try:
hulk(X,P) :-
       writef('NO'), nl.

call it with:

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

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.

867 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now