1:Implement methods and test if they work fine. GPT’s answer is what I want. Ple
1:Implement methods and test if they work fine. GPT’s answer is what I want. Please use basic recursion method, to make code easy and readable.
2: Consider the following Prolog rules. Trace the following query to demonstrate the step-by-step trace of how Prolog determined the result; do this cleanly and legibly, including both fail and successful calls.
You need to save this as a pdf or jpg file named “picture1” to show the process.
eo(L, [], L).
eo([], L, L).
eo([H1|T1], [H2|T2], [H1,H2|T]) :- eo(T1, T2, T).
Query: eo([1,2,3,4,5], [a,b,c], L).
3: Repeat the previous problem for the following rules query.
You need to save this as a PDF or jpg file named “picture2” to show the process.
enigma2(A, [A|_]) :- !.
enigma2(A, [_|T]) :- enigma2(A, T).
enigma([A,B|_], [A|T2]) :- enigma2(B, T2), !.
enigma([A,B|T1], [_|T2]) :- enigma([A,B|T1], T2).
Queries:enigma([1,2],[1,1,2]).
There are two files, already attached.
Leave a Reply