users-prolog
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Dynamic Allocation seems to crash gprolog


From: Daniel Diaz
Subject: Re: Dynamic Allocation seems to crash gprolog
Date: Fri, 14 Dec 2001 08:38:56 +0100

I Leonardo,

It is difficult to help you since 1) you dont give us a query that fails and 2) 
we cannot even
compile your program
(areChildrenOf is not defined as an operator, thus line #12 has an error and 
predicate
areChildrenOf/2 nor printChildren/1 is defined).... Give us more info !

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...



"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'



reply via email to

[Prev in Thread] Current Thread [Next in Thread]