Q 10. Write a prolog procedure every-other/2 that receives a source list as its first argu- ment and produces a list in
Posted: Mon Jun 06, 2022 12:12 pm
Q 10. Write a prolog procedure every-other/2 that receives a source list as its first argu- ment and produces a list in the second argument whose elements are the elements of odd indexes in the source list. Examples are given in the following: ?- every-other ([], L) L = []. ?- every-other ([1], L) L = [1]. ?- every-other ([1, 2], L) L = [1]. ?- every-other ([1, 2, 3], L) L = [1, 3]. ?- every-other ([1, 2, 3, 4], L) L = [1, 3]. Make sure your procedure is efficiently terminated.