にリストを形成するいくつかの要素を追加します。私は、追加使用してみましたが、私いるプロローグ - 私はこのような別のリストからいくつかの要素を追加する必要があり、別の1
find_same(pt(1,1),pt(2,2),6,[slope(6,pt(3,3)),slope(6,pt(4,4)),slope(7,pt(3,2)),slope(9,pt(5,5))],NL).
結果
NL=[pt(1,1),pt(2,2),pt(3,3),pt(4,4)]
find_same(_,_,_,[],_):-!.
find_same(pt(X,Y),pt(Xa,Ya),R,Slopes,Nl):-X\=a,
append(Nla,[pt(X,Y),pt(Xa,Ya)],Nl),
find_same(pt(a,a),pt(b,b),R,Slopes,Nla).
find_same(pt(X,Y),pt(Xa,Ya),R,[slope(R,pt(Xs,Ys))|Ss],Nl):-X=a,
append(Nla,[pt(Xs,Ys)],Nl),
find_same(pt(X,Y),pt(Xa,Ya),R,Ss,Nla).
find_same(_,_,R1,[slope(R2,_)|_],_):-R1\=R2,!.
私は多くのリストを返すので、いくつかの問題があります。
はその後、私は、この他のコードで試してみました:
find_same2(_,_,_,[],_):-!.
find_same2(pt(X,Y),pt(Xa,Ya),R,Slopes,_):-X\=a,
find_same2(pt(a,a),pt(b,b),R,Slopes,[pt(X,Y),pt(Xa,Ya)]).
find_same2(pt(X,Y),pt(Xa,Ya),R,[slope(R,pt(Xd,Yd))|Ss],[pt(Xd,Yd)|Nl]):-
X=a,!,
find_same2(pt(X,Y),pt(Xa,Ya),R,Ss,Nl).
find_same2(_,_,R1,[slope(R2,_)|_],_):-R1\=R2.
しかし、それだけでfalseを返します。
どうすればこの問題を解決できますか?ありがとう