[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Dynamic Allocation seems to crash gprolog
From: |
Leonardo B. Lopes |
Subject: |
Re: Dynamic Allocation seems to crash gprolog |
Date: |
Fri, 14 Dec 2001 11:22:10 -0600 (CST) |
I apologize for that. The whole code is actually almost 200 lines, and I
thought that I had a closed set of predicates. Here are the missing
predicates and an example query that fails:
/* Leaf */
leaf(Node) :- _ is_parent Node, \+ Node is_parent _2.
/* Set are the
children on Node */
:- op(500,xfx,'areChildrenOf').
[] areChildrenOf Node :- leaf(Node).
Set areChildrenOf Node :- setof(Child,Node is_parent Child,Set).
printTree(X) :- write('$'),
C areChildrenOf X,
printChildren(C),
write('^').
printChildren([]):- !.
printChildren([H|T]) :- printTree(H),
printChildren(T), !.
I attached a small terminal session that shows how the code fails.
> BTW the current stable version is 1.2.8 and fixes some bugs with dynamic
> code. see
> http://gprolog.inria.fr for more information on how to download it...
This is important info! Thanks for the heads up. I didn't know what had
changed between versions, so I wasn't sure if upgrading would solve my
problem. If I could make a suggestion, it would be helpful to have a
change log specifying what has changed from one version to the next...
Maybe it is there but I couldn't find it. So I'll upgrade and see if the
problem persists. I'll get back to you later. Thanks for your help!
Leo.
>
>
>
> "Leonardo B. Lopes" wrote:
> >
> > Dear Friends:
> >
> > I have this little routine which does a search over special trees.
> > I would like to delete the tree once it is no longer useful, but this code
> > seems to crash gprolog. Is there something I'm doing wrong?
> >
> > :- dynamic(parent/2,root/1,is_parent/2,is_root/1).
> >
> > :- op(500,xfx,(is_parent)).
> >
> > :- op(500,xfx,'has_children').
> > X has_children 0 :- leaf(X).
> > X has_children Y :- setof(Children, X is_parent Children, Set),
> > length(Set,Y).
> >
> > printTree(X) :- write('$'),
> > C areChildrenOf X,
> > printChildren(C),
> > write('^').
> >
> > createBalancedTree([],_):- !.
> > createBalancedTree([RootDegree|DegreeList],Tree) :-
> > new_atom(Tree),
> > for(_,1,RootDegree),
> > createBalancedTree(DegreeList,Child),
> > asserta( Tree is_parent Child),
> > Tree has_children RootDegree.
> >
> > deleteTree(Tree) :-
> > Tree is_parent X,
> > retract(Tree is_parent X),
> > deleteTree(X).
> >
> > Also, any other trees previously defined also get deleted when I use
> > deleteTree. BTW, I'm using gprolog 1.2.1.
> >
> > Appreciate any help!
> > Leo.
> >
> > ========================================================================
> > Leonardo B. Lopes address@hidden
> > Ph.D. Student (847)491-8470
> > IEMS - Northwestern University http://www.iems.nwu.edu/~leo
> >
>
>
> --
> Daniel Diaz address@hidden
> http://pauillac.inria.fr/~diaz
> gprolog --version 2>&1 | sed -n -e 's/By //p'
>
========================================================================
Leonardo B. Lopes address@hidden
Ph.D. Student (847)491-8470
IEMS - Northwestern University http://www.iems.nwu.edu/~leo
tree.pl
Description: Text document
gprolog.output
Description: Binary data