Write a Prolog function removeSecond which removes the secon
Write a Prolog function removeSecond which removes the second element of a given list. For example:
removeSecond ([A [A B] C], L)
Returns L = [A C] and
removeSecond ([A B [C D]], L)
Returns L = [A [C D]]
Thanks a lot for your help!!!
Solution
remove( [] , [] ) remove( [A] , [A] ) remove( [_,A] , [A] ) remove( [A|As] , [A|Bs] ) As = [_,_|_], remove(As,Bs)![Write a Prolog function removeSecond which removes the second element of a given list. For example: removeSecond ([A [A B] C], L) Returns L = [A C] and removeSe Write a Prolog function removeSecond which removes the second element of a given list. For example: removeSecond ([A [A B] C], L) Returns L = [A C] and removeSe](/WebImages/30/write-a-prolog-function-removesecond-which-removes-the-secon-1086636-1761571486-0.webp)