projog

3.105. min_list / max_list

Examples

?- min_list([], X).

no

?- max_list([], X).

no

?- min_list([1,2,3], 1).

yes

?- min_list([1,2,3], 2).

no

?- min_list([1,2,3], 3).

no

?- max_list([1,2,3], 1).

no

?- max_list([1,2,3], 2).

no

?- max_list([1,2,3], 3).

yes

?- min_list([7], 7).

yes

?- max_list([7], 7).

yes

?- min_list([2*7], 14).

yes

?- min_list([2*7], 2*7).

no

?- min_list([14], 2*7).

no

?- max_list([2*7], 14).

yes

?- min_list([2*7], 2*7).

no

?- max_list([14], 2*7).

no

?- min_list([11*2, 7*3, 92/4], X).
X = 21

yes

?- max_list([11*2, 7*3, 92/4], X).
X = 23

yes

?- min_list([Y], X).

Cannot get Numeric for term: Y of type: VARIABLE

?- max_list([[1]], X).

Cannot get Numeric for term: .(1, []) of type: LIST

?- min_list([a], X).

Cannot find arithmetic operator: a/0

?- max_list([q(1,2)], X).

Cannot find arithmetic operator: q/2

?- min_list(Y, X).

Expected LIST but got: VARIABLE with value: Y

?- max_list(a, X).

Expected LIST but got: ATOM with value: a

?- min_list([1,2|Y], X).

Expected LIST but got: VARIABLE with value: Y

?- max_list([1,2|Y], X).

Expected LIST but got: VARIABLE with value: Y