Solved

Simple function in Prolog

Posted on 2013-06-06
1
276 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

808 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