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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

please help me with this small problem

Status
Not open for further replies.

tarek90

Technical User
Nov 15, 2010
2
JO
Write a predicate min with the following property: min(A,B) succeeds
iff A is a list of numbers and B is the minimum value in the list. E.g.,
min([4,1,5,9,3],X) should succeed with X = 1.
 
What did you try ?
You should read other threads on this forum, you would find the solution.
 
for simple atomic statement

max(X,Y,X):-X >= Y.
max(X,Y,Y):-X < Y.

And for one list of numbers.

maxLis( [] ).
maxList( [E],E ).
maxList( [E,E2 | T],L ):-maxList( [E2 | T],L1 ),max(L1,E,L).

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top