{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

# hw9 - ●(a Write a predicate reverse(X,Y that is true if...

This preview shows pages 1–2. Sign up to view the full content.

Suggested Homework #9 Suggested Homework #9 (for Quiz #9 on 12/6/06) Problem 1. Recall the following prolog predicate described in class: parent(kim,holly). parent(margaret,kim). parent(herbert,margaret). parent(john,kim). parent(felix,john). parent(albert,felix). In addition, suppose we define the following predicates: male(herbert). male(john). male(felix). male(albert). female(kim). female(holly). female(margaret). (a) Write a predicate sibling(X,Y) that is true if X is a sibling of Y . (b) Write a predicate uncle(X,Y) that is true if X is an uncle of Y . (c) Write a predicate niece(X,Y) that is true if Y is a niece of X . (d) Write a predicate first_cousin(X,Y) that is true if X and Y are first cousins (i.e. they have parents who are siblings). (e) Write a predicate cousin(X,Y) that is true if X and Y are cousins (i.e. including first, second, third etc. cousins). Problem 2. List manipulation

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ● (a) Write a predicate reverse(X,Y) that is true if the list Y is the reverse of the list X . ● (b) Write a predicate sum(L,N) that is true if the number N is the sum of the numbers in the list L . http://www.cs.ucsd.edu/classes/fa06/cse130/shw/shw9.html (1 of 2) [2/13/2008 5:27:40 PM] Suggested Homework #9 ● (c) Write a predicate max(L,N) that is true if the number N is the largest (maximum) of the numbers in the list L . ● (d) Write a predicate sorted(L) that is true if the list L is sorted in increasing order. ● (e) Write a predicate subsequence(L1,L2) that is true if the list L2 is a subsequence of the list L1 . For example: subsequence([1,2,3,4],[2,4]) and subsequence([1,2,3],) but not subsequence([1,2,3],[3,1]) . http://www.cs.ucsd.edu/classes/fa06/cse130/shw/shw9.html (2 of 2) [2/13/2008 5:27:40 PM]...
View Full Document

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern