Article View: comp.lang.prolog
Article #199Re: ?: Efficient implementation of HASHING in PROLOG
From: Peter Ludemann
Date: Tue, 14 Apr 1992 18:14
Date: Tue, 14 Apr 1992 18:14
20 lines
1437 bytes
1437 bytes
In article <1992Apr9.004044.22425@athena.cs.uga.edu>, mcovingt@athena.cs.uga.edu (Michael A. Covington) writes: > Prolog already uses hashing to look up facts and rules. Hashing is > applied to the predicate name itself (with arity) and (in most > implementations) to the first argument of the predicate. And in some Prologs, the hashing function is available to programmers, so that complex terms can be hashed. So, for example, you can do: foo(X,Y,Z) :- hash_term(X-Y,Hash), foo2(Hash,X,Y,Z). add_foo(X,Y,Z) :- hash_term(X-Y,Hash), assertz(foo2(Hash,X,Y,Z)). Note that this depends on hash_term/2 returning a variable whenever its first argument is not ground. [If your Prolog implementation doesn't have hash_term/2, writing a C function to implement it is a good test of how good the C interface is.] -- Peter Ludemann +1-415-813-3800 ludemann@quintus.com
Technical Details
Message-ID:
<1992Apr14.181452.6752@quintus.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!infonode!ingr!capalo!quintus!quintus!ludemannReferences:
<1992Apr8.234624.7922@cl.cam.ac.uk> <1992Apr9.004044.22425@athena.cs.uga.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.prolog Path: arc1-ca.pugleaf.net!sparky!uunet!infonode!ingr!capalo!quintus!quintus!ludemann From: ludemann@quintus.com (Peter Ludemann) Subject: Re: ?: Efficient implementation of HASHING in PROLOG Message-ID: <1992Apr14.181452.6752@quintus.com> Keywords: Prolog, Hashing Sender: news@quintus.com (USENET news account) Nntp-Posting-Host: ebisu Organization: Quintus Corporation, Palo Alto, CA References: <1992Apr8.234624.7922@cl.cam.ac.uk> <1992Apr9.004044.22425@athena.cs.uga.edu> Date: Tue, 14 Apr 1992 18:14:52 GMT Lines: 20