Discussions related to Visual Prolog
ahmednadi
Active Member
Posts: 37
Joined: 15 Sep 2009 14:06

Dynamic variable

Unread post by ahmednadi »

Dear Sir;
I would like to define a dynamic variable such as clauseX = clauseX(subclauseX,subclauseX).

Code: Select all

subclauseX = subclauseX1(phraseX);                     subclauseX2(phraseX,phraseX);                     subclauseX3(phraseX,phraseX,phraseX);                     subclauseX4(phraseX,phraseX,phraseX,phraseX);                     subclauseX5(phraseX,phraseX,phraseX,phraseX,phraseX).
Meanwhile, when I use this variable subclauseX1(phraseX) to pick the first result in a loop and I can't add the second result subclauseX2(phraseX,phraseX) and the third subclauseX3(phraseX,phraseX,phraseX) and so on
But the outputs of each cycle in the loop should not exceed the fifth cycle. A notice should be displayed and fail.

Code: Select all

test:(string*,string*,string*,string*,string*,phraseX,string*) determ(i,i,i,o,o,o,o).

Code: Select all

sent:(string*,string*,clauseX) determ(i,i,o).

Code: Select all

sent([],_,_):-!. sent(_,[],_):-!. sent(WLst,XLst,clauseX(Phrase)):-!, test(WLst,XLst, WLst2, XLst2,Phrase). sent(WLst2,XLst2,clauseX(Phrase)).
Regards;
AHMED NADY
Harrison Pratt
VIP Member
Posts: 439
Joined: 5 Nov 2000 0:01

Unread post by Harrison Pratt »

You said, if I interpret correctly, that you want to check subclauseX1 through sublcauseX5. However, you have ";" (logical OR) where I believe there should be "," (logical AND) so only the first succeeding subclauseXn will be executed.

I have a feeling that you have tried to simplify the problem for the discussion group and may have some typographic errors.

Code: Select all

subclauseX = subclauseX1(phraseX) ;                     subclauseX2(phraseX,phraseX) ;                     subclauseX3(phraseX,phraseX,phraseX) ;                     subclauseX4(phraseX,phraseX,phraseX,phraseX) ;                     subclauseX5(phraseX,phraseX,phraseX,phraseX,phraseX).
Please try re-stating your question.
User avatar
Thomas Linder Puls
VIP Member
Posts: 1398
Joined: 28 Feb 2000 0:01

Unread post by Thomas Linder Puls »

I also have problems undestanding the problem.

A "strict" formatting of your code looks like this:

Code: Select all

    sent([], _, _) :-         !.       sent(_, [], _) :-         !.       sent(WLst, XLst, clauseX(Phrase)) :-         !,         test(WLst, XLst, WLst2, XLst2, Phrase).       sent(WLst2, XLst2, clauseX(Phrase)).
The two clauses seems "strange", the variable names implies that it should have been a single clause, but the use of "clauseX(Phrase)" seems to contradict this.
Regards Thomas Linder Puls
PDC
Post Reply