使用cut,ERROR:超出本地堆栈

时间:2015-11-17 13:50:31

标签: prolog prolog-cut

这是我的代码,只关注最后3条规则:

content = eval("<%= escape_javascript render(:partial => 'events/bookmarklet') %>");                                                                                  
SyntaxError: (eval):1: syntax error, unexpected '<'
<%= escape_javascript render(:partial => 'events/bookmarklet') %>
 ^
(eval):1: syntax error, unexpected ')', expecting end-of-input
<%= escape_javascript render(:partial => 'events/bookmarklet') %>
                                                              ^
from (pry):12:in `eval'

我不关心任何其他答案,只是回答这个问题:

father(costac,anne). 
mother(mary,mike). 
husband(costac,mary). 
sex_male(costac). 
sex_male(mike). 
sex_female(mary). 
sex_female(anne). 


mother(X,Y):-
        father(Z,Y),
        wife(X,Z).
father(X,Y):-
        mother(Z,Y),
        husband(X,Z).
husband(X,Y):-
        wife(Y,X).
wife(X,Y):-
        husband(Y,X).
husband(X,Y):-
        father(X,Z),
        mother(Y,Z).
wife(X,Y):-
        father(Y,Z),
        mother(X,Z).
brother(X,Y):-
        father(Z,Y),
        father(Z,X),
        sex_male(X),
        \+ X = Y.
brother(X,Y):-
        mother(Z,Y),
        mother(Z,X),
        sex_male(X),
        \+ X = Y.

sister(X,Y):-
        father(Z,X),
        sex_female(X),
        father(Z,Y),
        \+ X = Y.
sister(X,Y):-
        mother(Z,X),
        sex_female(X),
        mother(Z,Y),
        \+ X = Y.

find_rel(Ans):-
        write('Please give first name: '), read(X),
        find(X,Ans).
find(X,Ans):-
        write('Would you like to give second name? -yes/no-'), nl, read(Ask), find_ans(Ask,X,Ans).
find_ans(yes,X,Ans):-
        write('Please give second name: '), read(Y),nl,
        (father(X,Y),!, Ans = father(X,Y));
        (mother(X,Y), !,Ans = mother(X,Y));
        (husband(X,Y), !,Ans = husband(X,Y));
        (wife(X,Y), !,Ans = wife(X,Y));
        (brother(X,Y), !,Ans = brother(X,Y));
        (sister(X,Y), Ans = sister(X,Y)).
/*find_ans(no,X,Ans):-....*/

给出名称costac&amp;安妮,我确实得到了我想要的东西,因为这是我统治的第一线。我尝试的其他所有内容都失败了,并给出了标题的错误! 我尝试过使用剪切,但没有任何效果。当我追踪时,例如我给玛丽&amp;迈克,我看到的是,即使它进入步骤?-find_rel(Ans). 并生成(mother(X,Y), !,Ans = mother(X,Y));也忽略它,然后转到接下来的两个并继续循环:

mother(mary,anne)

0 个答案:

没有答案