LoginSignup
23JON
@23JON (23 JON)

Are you sure you want to delete the question?

If your question is resolved, you may close it.

Leaving a resolved question undeleted may help others!

We hope you find it useful!

ProLogプログラムの確認

以下に示すリスト要素の合計を求めるProLogプログラムの実行過程を示せ.
conc([], L, L).
conc([H | T], L, [H | C]) :- conc(T, L, C).
conc([1, 2, 3], [4, 5], X)

との問題が出題されたのですが、答は以下で正しいでしょうか。

<答>

conc([1, 2, 3] , [4, 5] , X)
=conc([ 1 | [2, 3] ] , [4, 5] , [1 | X1]) :― conc([2, 3] , [4, 5] ,X1)
=conc([2 | [3] ] , [4, 5] , [2 | X2]) :― conc([3] , [4, 5] , X2)
=conc([3 | [] ] , [4, 5] , X2) :― conc([] , [4, 5] , X3)
X3=[4, 5]→X2=[3, 4, 5]→X1=[2, 3, 4, 5]→X=[1, 2, 3, 4, 5]

1

No Answers yet.

Your answer might help someone💌