Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

urgent prolog (arithmetic)

Status
Not open for further replies.

mosk

Programmer
Joined
Feb 23, 2004
Messages
1
Location
GB

hi guys can help will prolog questions
1. Write the following two predicates without using arithmetic.
(a) Define a predicate mult3 length such that mult3 length(Xs) holds if
and only if Xs is a list and the length of Xs is a multiple of 3.
(b) Define a predicate ge5 length such that ge5 length(Xs) holds if and
only if Xs is a list that has a length of at least 5.

2. Define a predicate sorted such that sorted(Xs) holds of a list of integers Xs
if and only if Xs is sorted.
3. Define a predicate sublist such that sublist(Xs, Ys) holds if and only if Ys
is a sublist of Xs. For example,
?- sublist( [ a, b, c, d, e ], [ a, b, d ] ).
yes
?- sublist( [ a, b, c, d, e ], [ c, b ] ).
no
?- sublist( [ a, b, c, d, e ], [ a, k, e ] ).
no
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top