|
View:
New views
3 Messages
—
Rating Filter:
Alert me
|
|
|
=../2 in the body of term_expansion/2 failsIn my previous message I made typo =../3 for =../2 I am sorry for possible confusions. The following is the current code that works as expected. copy_args(I, J, _, _):- I> J,!. copy_args(I, J, G, G0):- arg(I, G, A), arg(I, G0, A), I0 is I+1, copy_args(I0, J, G, G0). :- if(guarded). goal_expansion(G, (check_call(F, N), G0)):- functor(G, scall, N0), !, functor(G0, call, N0), copy_args(1,N0,G, G0), arg(1, G, F), N is N0-1. :- else. goal_expansion(G, G0):- functor(G, scall, N0), !, functor(G0, call, N0), copy_args(1, N0,G, G0). :-endif. Kuniaki > > Is the builtin predicate =../3 not allowed in > the body for term_expansion/2 definitions ? > > I wrote term_expansion/2 definition using =../2 in the body, > but it (=../2 call) fails on compiling (loading). > So I rewrote the definition replacing =../2 in the body > with functor/3, then the term_expansion has worked > well in the way as I intended. > > I can not find any reason for that the builtin =../3 is > not allowed to be used for term_expansion/2. > > Thank you for pointing out in advance what I am missing > > Kuiaki Mukai > > SWI-Prolog mailing list SWI-Prolog@... https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog |
|
|
Re: =../2 in the body of term_expansion/2 failsYou can certainly use =../2 in goal/term expansion. Most likely you made
some subtle mistake. Note that you can simply place a spy-point on the expansion predicate to debug it. --- Jan On Monday 02 November 2009 09:48:52 pm Kuniaki Mukai wrote: > In my previous message I made typo =../3 for =../2 > I am sorry for possible confusions. > > The following is the current code that works as expected. > > copy_args(I, J, _, _):- I> J,!. > copy_args(I, J, G, G0):- arg(I, G, A), arg(I, G0, A), > I0 is I+1, copy_args(I0, J, G, G0). > > :- if(guarded). > > goal_expansion(G, (check_call(F, N), G0)):- > functor(G, scall, N0), > !, > functor(G0, call, N0), > copy_args(1,N0,G, G0), > arg(1, G, F), > N is N0-1. > > :- else. > > goal_expansion(G, G0):- > functor(G, scall, N0), > !, > functor(G0, call, N0), > copy_args(1, N0,G, G0). > > :-endif. > > Kuniaki > > > Is the builtin predicate =../3 not allowed in > > the body for term_expansion/2 definitions ? > > > > I wrote term_expansion/2 definition using =../2 in the body, > > but it (=../2 call) fails on compiling (loading). > > So I rewrote the definition replacing =../2 in the body > > with functor/3, then the term_expansion has worked > > well in the way as I intended. > > > > I can not find any reason for that the builtin =../3 is > > not allowed to be used for term_expansion/2. > > > > Thank you for pointing out in advance what I am missing > > > > Kuiaki Mukai > > _______________________________________________ > SWI-Prolog mailing list > SWI-Prolog@... > https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog _______________________________________________ SWI-Prolog mailing list SWI-Prolog@... https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog |
|
|
Re: =../2 in the body of term_expansion/2 failsJan, Thank you for your definite answer. According to your answer, I have made another try with =../2 as below. It works !! Now it is certain that I made some kind of a stupid mistake on the first try with =../2, though I can not identify it. Actually it was my first time to use term_expansion/2 or goal_expansion/2. Perhaps, I was so excited to realize powerful functions of these predicates with unbelievable simple usage that I went to lose my usual state of mind :-) :- if(guarded). goal_expansion(G, (check_call(F, N), G0)):- G=..[scall,F|Args], !, G0=..[call,F|Args], length(Args, N). :- else. goal_expansion(G, G0):- G=..[scall|Args], !, G0=..[call|Args]. :-endif. Kuniaki On Nov 3, 2009, at 5:42 PM, Jan Wielemaker wrote: > You can certainly use =../2 in goal/term expansion. Most likely you > made > some subtle mistake. Note that you can simply place a spy-point on the > expansion predicate to debug it. > > --- Jan > > On Monday 02 November 2009 09:48:52 pm Kuniaki Mukai wrote: >> In my previous message I made typo =../3 for =../2 >> I am sorry for possible confusions. >> >> The following is the current code that works as expected. >> >> copy_args(I, J, _, _):- I> J,!. >> copy_args(I, J, G, G0):- arg(I, G, A), arg(I, G0, A), >> I0 is I+1, copy_args(I0, J, G, G0). >> >> :- if(guarded). >> >> goal_expansion(G, (check_call(F, N), G0)):- >> functor(G, scall, N0), >> !, >> functor(G0, call, N0), >> copy_args(1,N0,G, G0), >> arg(1, G, F), >> N is N0-1. >> >> :- else. >> >> goal_expansion(G, G0):- >> functor(G, scall, N0), >> !, >> functor(G0, call, N0), >> copy_args(1, N0,G, G0). >> >> :-endif. >> >> Kuniaki >> >>> Is the builtin predicate =../3 not allowed in >>> the body for term_expansion/2 definitions ? >>> >>> I wrote term_expansion/2 definition using =../2 in the body, >>> but it (=../2 call) fails on compiling (loading). >>> So I rewrote the definition replacing =../2 in the body >>> with functor/3, then the term_expansion has worked >>> well in the way as I intended. >>> >>> I can not find any reason for that the builtin =../3 is >>> not allowed to be used for term_expansion/2. >>> >>> Thank you for pointing out in advance what I am missing >>> >>> Kuiaki Mukai >> >> _______________________________________________ >> SWI-Prolog mailing list >> SWI-Prolog@... >> https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog > > _______________________________________________ > SWI-Prolog mailing list > SWI-Prolog@... > https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog _______________________________________________ SWI-Prolog mailing list SWI-Prolog@... https://mailbox.iai.uni-bonn.de/mailman/listinfo.cgi/swi-prolog |
| Free embeddable forum powered by Nabble | Forum Help |