Article View: comp.lang.prolog
Article #1103Re: Arrays in Prolog
From: R. Kym Horsell
Date: Mon, 27 Aug 1990 21:20
Date: Mon, 27 Aug 1990 21:20
34 lines
2040 bytes
2040 bytes
In article <90239.175243SCHMIED@DB0TUI11.BITNET> SCHMIED@tubvm.cs.tu-berlin.de (Albrecht Schmiedel) writes: \\\ >My questions are the following: >1) Are there Prologs that adress this kind of need? > (I.e. Prologs that make assertions, retractions, and calls > involving predicates that fulfill certain conditions > - for example, a guaranteed instantiated integer as its first > argument, one clause per integer, no backtracking - > similarly fast as array operations.) >2) Are there Prologs which are easily extendable by predicates > written in C that could do the job? > (It should be possible to pass *terms* back and forth; > having to decompose terms and lists before processing them > by a foreign language predicate and then having to put them > together again later on is definitely not what we want.) >3) Shouldn't we be using Prolog? >4) Is there a 'Prolog-way' of handling large graphs efficiently? > (Graphs where data referencing other nodes is attached to nodes, > and search as well as updates are required.) So it's come to this -- destructive assignment in Prolog! There are several methods for implementing arrays in Prolog and the one I have implemented is a variant of the setarg/3 precicate that also appears elsewhere. setarg(Index,Term,Value) replaces argument ``index'' in ``term'' with ``value'' but allows backtracking so that ``term'' may be restored to its former state -- no destructuve assignment happens unless you setarg(X,Y,Z), !. -Kym Horsell
Technical Details
Message-ID:
<3899@bingvaxu.cc.binghamton.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!leah!bingvaxu!vu0310References:
<90239.175243SCHMIED@DB0TUI11.BITNET>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!leah!bingvaxu!vu0310 From: vu0310@bingvaxu.cc.binghamton.edu (R. Kym Horsell) Newsgroups: comp.lang.prolog Subject: Re: Arrays in Prolog Message-ID: <3899@bingvaxu.cc.binghamton.edu> Date: 27 Aug 90 21:20:07 GMT References: <90239.175243SCHMIED@DB0TUI11.BITNET> Reply-To: vu0310@bingvaxu.cc.binghamton.edu.cc.binghamton.edu (R. Kym Horsell) Organization: SUNY Binghamton, NY Lines: 34