Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!csd4.milw.wisc.edu!lll-winken!uunet!mcvax!prlb2!kulcs!bimbart From: bimbart@kulcs.uucp (Bart Demoen) Newsgroups: comp.lang.prolog Subject: blam Message-ID: <1636@kulcs.kulcs.uucp> Date: 10 Apr 89 08:44:19 GMT Reply-To: bimbart@kulcs.UUCP (Bart Demoen) Organization: Katholieke Universiteit Leuven, Dept. Computer Science Lines: 43 In response to <674@tuvie> <678@tuvie> ulrich@vip.UUCP (Ulrich Neumerkel) : We changed blam/2 to: blam(0,[]). blam(N,f(L,L)) :- N > 0, M is N - 1, blam(M,L). (the list was changed to a functor with arity 2) In BIMprolog ?- blam(32,_l) , assert(little_fact(_l)) . doesn't work but ?- blam(32,_l) , record(key,_l) . does, since our record predicates preserve the sharing of structures (not yet of lists) and likewise recorded(key,_l) produces a structure on the heap with all the original sharing. ( record/2 stores its second argument with the first argument as key recorded/2 retrieves the structure associated with the first argument ) In response to <1717@etive.ed.ac.uk> jha@lfcs.ed.ac.uk (Jamie Andrews) : > I think most Prolog implementations would do this sensibly, > representing this as 32 cons cells with both pointers pointing > ... On the heap ok, but in code - eg WAM code - that's another matter: even the most sensible Prolog implementations might not search for common substructures; taking sharing into account, the WAM code for little_fact/1 could be something like: GET_LIST A1 UNIFY_XVAR A1 UNIFY_XVAL A1 GET_LIST A1 UNIFY_XVAR A1 UNIFY_XVAL A1 ... (in total 32 GET_LISTs) UNIFY_NIL UNIFY_NIL bimbart@kulcs bimandre@kulcs