Xref: utzoo comp.sys.amiga:20932 comp.lang.prolog:1073 Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!killer!ames!pasteur!agate!ig!arizona!debray From: debray@arizona.edu (Saumya Debray) Newsgroups: comp.sys.amiga,comp.lang.prolog Subject: Re: SBProlog and clause/2.. Summary: clause/2, sbprolog Message-ID: <6183@megaron.arizona.edu> Date: 10 Jul 88 15:33:12 GMT References: <732@kuling.UUCP> Organization: U of Arizona CS Dept, Tucson Lines: 38 In article <732@kuling.UUCP>, jonasf@kuling.UUCP (Jonas Flygare) writes: > I would appreciate any help on implementing clause/2 in SBProlog, > as it would provide a crude listing/1 facility in conjunction with > bagof/3. The main reason sbprolog doesn't have clause/2 or clause/3 is that in four years of working with Prolog, none of us really found a need for it in our work (which is not to say that they're useless, it's just that there were other, more immediately useful, things for us to work on). The system is currently undergoing a major overhaul to overcome some alignment restrictions that prevent the current version from being ported to machines like the Sun-4. We expect to include clause/2 and clause/3 in the next release (hopefully, within a month). Meanwhile, the following quick hack provides a poor man's clause/2 on sbprolog: cassert( Cl ) :- (Cl = (H :- B) -> true ; (H = Cl, B = true) ), assert(Cl), assert($clausedb(H,B)). clause(H, B) :- $clausedb(H, B). Predicates asserted through cassert/1 instead of assert/1 can be accessed through clause/2. It should be straightforward to add an option to consult/2 to make it call either assert/1 or cassert/1. (I admit this isn't a very efficient solution, since the work involved in asserting clauses is effectively being doubled. Like I said, it's a quick hack ...). -- Saumya Debray CS Department, University of Arizona, Tucson internet: debray@arizona.edu uucp: arizona!debray