Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Value Assignment Operator
Hi All,

I am trying to assign a variable the value of another variable - so I am
looking for something of the form X = Y, where X would have the value of
Y rather than checking if X is equal to Y or not. I saw something about
using :=, but this does not compile under both Sicstus Prolog and SWI
Prolog.

I look forward to hearing from you soon.

Regards,
George

Report this thread to moderator Post Follow-up to this message
Old Post
George
04-03-08 12:39 AM


Re: Value Assignment Operator
On Apr 2, 1:08 pm, George <m...@me.com> wrote:
> Hi All,
>
> I am trying to assign a variable the value of another variable - so I am
> looking for something of the form X = Y, where X would have the value of
> Y rather than checking if X is equal to Y or not. I saw something about
> using :=, but this does not compile under both Sicstus Prolog and SWI
> Prolog.
>
> I look forward to hearing from you soon.
>
> Regards,
> George

Use is/2, for example X is 2+3.

regards, chip

Report this thread to moderator Post Follow-up to this message
Old Post
Chip Eastham
04-03-08 12:39 AM


Re: Value Assignment Operator
On Apr 2, 1:08 pm, George <m...@me.com> wrote:
> Hi All,
>
> I am trying to assign a variable the value of another variable - so I am
> looking for something of the form X = Y, where X would have the value of
> Y rather than checking if X is equal to Y or not. I saw something about
> using :=, but this does not compile under both Sicstus Prolog and SWI
> Prolog.
>
> I look forward to hearing from you soon.
>
> Regards,
> George

Actually when you are dealing with variables X and Y,
the subgoal X=Y may have your desired effect.  Rather than
"assignment", the Prolog terminology would be to "unify"
these two variables.  So X=Y checks to see if these
expressions can be unified, and succeeds by effectively
treating them as thereafter bound to one another.

The "assignment" X=Y can fail only if X and Y are already
bound to expressions that cannot be unified.  Where you
may be frustrated is the fundamental design of Prolog in
not allowing reassigning values to a variable.  Once we
have succeeded in binding X = 2 and Y = 3, we cannot get
X = Y to succeed by "changing" the assignment of X.

regards, chip

Report this thread to moderator Post Follow-up to this message
Old Post
Chip Eastham
04-03-08 12:39 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

Prolog archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 05:09 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.