Re: [eclipse-clp-users] Question regarding the redefined variable

From: Choughule, Yogesh <Yogesh.Choughule_at_...390...>
Date: Mon, 15 Dec 2014 08:42:41 +0000
Hi Kish

Sorry for the misunderstanding. 
I am a beginner in Prolog, I will try to explain my question using Prolog code.

Consider the following code in which A is defined twice and gives an error.

:-lib(ic).

solve(A, B) :-

A $= 2,         % A defined as 2
B $= 3 + A,  % A is used to calculate B
A $= B + 2.  % A takes new value

My question is, 
Is there any way i can define A twice in the same code?


________________________________________
From: Kish Shen [kisshen@...5...]
Sent: 15 December 2014 17:23:29
To: Choughule, Yogesh; eclipse-clp-users_at_lists.sourceforge.net
Subject: Re: [eclipse-clp-users] Question regarding the redefined variable

Hi Rogesh,

 From your question, it seems you do not know Prolog -- ECLiPSe is an
implementation of Prolog, with additional libraries and features. You
really need to know Prolog in order to program in ECLiPSe, and most of
the documentation that comes with ECLiPSe requires some basic knowledge
of Prolog. The tutorial does give a very quick introduction to Prolog,
but it is probably still too brief to learn Prolog properly.

If you don't know Prolog, you probably need to get some textbook or
tutorial on Prolog or ECLiPSe, and

http://www.eclipseclp.org/reports/index.html

has pointers to various materials that may help.

I am having problems understanding the intention of your code fragments,
but I suspect they almost certainly are not what you intended, e.g.

A=3;
B=5;

the semi-colon (;) is not a statement separator in Prolog, it is a
disjunction.

 >A=B+3

is unifying A with the structure B+3, not the result of the expression B+3.

Cheers,

Kish

On 15/12/2014 01:52, Choughule, Yogesh wrote:
> Dear Users
>
> My question is regarding the redefined variable.
>
> Consider following code slice
>
> A=3;
> B=5;
> --
> --other constraints
> --
> A=B+3;   //A is redefined
>
> While giving the above constraints to ECLiPSe to solve A and B,
> error occurs because A is defined twice.
>
> 1) Should we rename A as A1 and use?
> 2) Is there any other way we can handle this situation?
>
>
> Thanks and Regards
>
> Yogesh C.
>
> ______________________________________________________________________
> Disclaimer: This email and any attachments are sent in strictest confidence
> for the sole use of the addressee and may contain legally privileged,
> confidential, and proprietary data. If you are not the intended recipient,
> please advise the sender by replying promptly to this email and then delete
> and destroy this email and any attachments without any further use, copying
> or forwarding.
>
>
>
> ------------------------------------------------------------------------------
> Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
> from Actuate! Instantly Supercharge Your Business Reports and Dashboards
> with Interactivity, Sharing, Native Excel Exports, App Integration & more
> Get technology previously reserved for billion-dollar corporations, FREE
> http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
>
>
>
> _______________________________________________
> ECLiPSe-CLP-Users mailing list
> ECLiPSe-CLP-Users_at_lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/eclipse-clp-users
>


______________________________________________________________________
Disclaimer: This email and any attachments are sent in strictest confidence
for the sole use of the addressee and may contain legally privileged,
confidential, and proprietary data. If you are not the intended recipient,
please advise the sender by replying promptly to this email and then delete
and destroy this email and any attachments without any further use, copying
or forwarding.
Received on Mon Dec 15 2014 - 08:42:51 CET

This archive was generated by hypermail 2.2.0 : Mon Jul 09 2018 - 02:05:30 CEST