Solved

Simple function in Prolog

Posted on 2013-06-06
1
275 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 AD Toolbox Looking More Like a Toybox?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB6 Compile Compatibility Issue 4 102
SUM 2 INTEGER ARRAYS INTO 1 10 101
Java Loop 6 62
Advice in Xamarin 21 80
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
A short article about problems I had with the new location API and permissions in Marshmallow
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.

831 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