Solved

Simple function in Prolog

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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
This is an explanation of a simple data model to help parse a JSON feed
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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.

759 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

18 Experts available now in Live!

Get 1:1 Help Now