🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.prolog
Article #4137

incrementing values

#4137
From: Saumya K. Debray
Date: Fri, 02 Feb 1990 03:52
29 lines
1266 bytes
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:
| 
| 	increment(Variable) :-
| 		retract(value(Variable, OldValue)),
| 		NewValue is OldValue + 1,
| 		assert(value(Variable, NewValue)).
| 
| 	..., increment(x), ...
| 
| 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?
-- 
Saumya Debray		CS Department, University of Arizona, Tucson

     internet:   debray@cs.arizona.edu
     uucp:       uunet!arizona!debray
Technical Details
Message-ID: <17467@megaron.cs.arizona.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!mailrus!ames!ig!arizona!debray

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!mailrus!ames!ig!arizona!debray
From: debray@cs.arizona.edu (Saumya K. Debray)
Newsgroups: comp.lang.prolog
Subject: incrementing values
Message-ID: <17467@megaron.cs.arizona.edu>
Date: 2 Feb 90 03:52:55 GMT
Organization: U of Arizona CS Dept, Tucson
Lines: 29