Article View: comp.lang.prolog
Article #4147Re: incrementing values
From: Aaron Sloman
Date: Sun, 04 Feb 1990 16:51
Date: Sun, 04 Feb 1990 16:51
45 lines
2252 bytes
2252 bytes
debray@cs.arizona.edu (Saumya K. Debray) writes:
> Date: 2 Feb 90 03:52:55 GMT
> Organization: U of Arizona CS Dept, Tucson
>
> This is an excerpt from an article posted recently to another newsgroup:
>
> | > the most frequently occuring construct in any programming language is
> | > equivalent to the construct x += 1
> |
> | Er, not quite *any* programming language. I have been programming
> | professionally in Prolog for the last five years, and I need to do
> | this sort of thing maybe once or twice a year.
> |
> | BTW, here's how to do it:
...stuff omitted...
> | but as this makes two modifications to the database and is therefore
> | pretty expensive (not to mention poor style), you don't want to do it
> | too often.
>
> Comments?
Some readers may be interested to know that it's not a problem in
Poplog prolog because users have full access via the Poplog virtual
machine to Pop-11 (or, if required, Lisp) global variables.
For example Poplog Prolog provides two built in predicates
prolog_setq(PopVariable, Value). /*sets value of pop variable*/
prolog_val(PopVariable, Value). /*gets value of pop variable*/
So, if you have a global Pop-11 variable "count" you can do things like
prolog_val(count, X), ...... prolog_setq(count, X + 1).
It is also possible for Poplog Prolog programs to access a full range of
Pop-11 data-structures including hash-tables, arrays, strings, etc. which
can considerably speed up some programs as well as making them clearer.
Aaron Sloman,
School of Cognitive and Computing Sciences,
Univ of Sussex, Brighton, BN1 9QH, England
EMAIL aarons@cogs.sussex.ac.uk
aarons%uk.ac.sussex.cogs@nsfnet-relay.ac.uk
Technical Details
Message-ID:
<2099@syma.sussex.ac.uk>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!icdoc!syma!aaronsReferences:
<17467@megaron.cs.arizona.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!uunet!mcsun!ukc!icdoc!syma!aarons From: aarons@syma.sussex.ac.uk (Aaron Sloman) Newsgroups: comp.lang.prolog Subject: Re: incrementing values Summary: Poplog Prolog can access Pop-11 variables. Keywords: incrementing, global variables, prolog Message-ID: <2099@syma.sussex.ac.uk> Date: 4 Feb 90 16:51:22 GMT References: <17467@megaron.cs.arizona.edu> Organization: School of Cognitive & Computing Sciences, Sussex Univ. UK Lines: 45